Prev: kill process
Next: split question
From: Petr Danes on 6 Jan 2010 15:39 I use the following code in VBA in an Access database to retrieve a custom database property: currentdb.Containers(1).Documents("Uzivatelske").Properties("Version") I would like to get this value via VBScript without opening the database. I have found many tutorials and examples on how to retrieve values form tables, but this is different and none of my attempts have met with any success. I have tried connections, objAcc.OpenCurrentDatabase and all sorts of other stuff, but all I get is various error messages. Are these values available to VBScript? Pete -- This e-mail address is fake, to keep spammers and their address harvesters out of my hair. If you need to get in touch personally, I am 'pdanes' and I use yahoo mail. But please use the newsgroups whenever possible, so that all may benefit from the exchange of ideas.
From: Bob Barrows on 6 Jan 2010 16:11 Petr Danes wrote: > I use the following code in VBA in an Access database to retrieve a > custom database property: > > currentdb.Containers(1).Documents("Uzivatelske").Properties("Version") > > I would like to get this value via VBScript without opening the > database. I have found many tutorials and examples on how to retrieve > values form tables, but this is different and none of my attempts > have met with any success. I have tried connections, You mean ADO connections? That will not work. This collection is not available for ADO > objAcc.OpenCurrentDatabase No that won't help. You need to use DAO. Start by creating an instance of the DBEngine: Set DE = CreateObject("DAO.DBEngine.36") Then open your database: Set db = DE.OpenDatabase("C:\Program Files\Microsoft" & _ "Office\Office\Samples\Northwind.mdb") Then go after the collection: msgbox db.Containers(1).Documents("Uzivatelske").Properties("Version") PS. I hope you are not doing this in ASP server-side code. DAO is single-threaded so it will make your ASP application thread-bound, impairing performance. Unfortunately, DAO is the only way to get at those properties. -- HTH, Bob Barrows
From: Petr Danes on 6 Jan 2010 18:28 Most excellent, Bob. Thankyouthankyouthankyou, that's exactly it. May I ask where you found this? And no, it's not anything like you describe. It's several copies of a single-machine, single-user, mostly read-only database, running on various computers in a library department. I want the copies to occasionally interrogate the master copy, but in a very non-intrusive way. The master machine may be shut down (it's not a server), or the db in use and I don't want the users being pestered with error messages, or to have to wait for timeouts. The intention here is for the db copies to spawn an invisible script process that quietly checks for certain conditions in the master copy, and only if all conditions are met, does it inform the user that a newer version is available and ask if it should be copied over. And a maximum of once per day - I don't want the users to be pestered by this dialog every time they start the db to look up something. If the proper conditions do not exist, or if the update dialog has already been dismissed once that day, the script process will simply close and the user should never even know that such an event took place. The data are not mission-critical or time-sensitive in any way - an update of once or twice per month should be more than adequate. Pete "Bob Barrows" <reb01501(a)NOyahoo.SPAMcom> p�e v diskusn�m p��sp�vku news:ug20oTxjKHA.1824(a)TK2MSFTNGP04.phx.gbl... > Petr Danes wrote: >> I use the following code in VBA in an Access database to retrieve a >> custom database property: >> >> currentdb.Containers(1).Documents("Uzivatelske").Properties("Version") >> >> I would like to get this value via VBScript without opening the >> database. I have found many tutorials and examples on how to retrieve >> values form tables, but this is different and none of my attempts >> have met with any success. I have tried connections, > > You mean ADO connections? That will not work. This collection is not > available for ADO > >> objAcc.OpenCurrentDatabase > > No that won't help. You need to use DAO. Start by creating an instance > of the DBEngine: > > Set DE = CreateObject("DAO.DBEngine.36") > > Then open your database: > Set db = DE.OpenDatabase("C:\Program Files\Microsoft" & _ > "Office\Office\Samples\Northwind.mdb") > > Then go after the collection: > msgbox db.Containers(1).Documents("Uzivatelske").Properties("Version") > > PS. I hope you are not doing this in ASP server-side code. DAO is > single-threaded so it will make your ASP application thread-bound, > impairing performance. Unfortunately, DAO is the only way to get at > those properties. > > -- > HTH, > Bob Barrows > > >
From: Bob Barrows on 6 Jan 2010 19:38 Petr Danes wrote: > Most excellent, Bob. Thankyouthankyouthankyou, that's exactly it. May > I ask where you found this? > :-) In my head ... I suppose you could find other examples by googling DAO and vbscript, but really, the key is just initializing the dbengine object. The rest of the code is pretty much what you would write in vba. For example, I just copied and pasted the last line I gave you, changing "currentdb" (which is not available in vbscript) to the "db" (database) variable. > And no, it's not anything like you describe. Good, you're good to go. -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
From: Petr Danes on 7 Jan 2010 05:37
It's specifically the CreateObject("DAO.DBEngine.36") that I was wondering about, thought maybe you knew of a scripting website or book with that. You're right, I probably could have gotten the rest myself, given that as a start. In any case, thank you again. Long live newsgroups. Pete "Bob Barrows" <reb01501(a)NOyahoo.SPAMcom> p�e v diskusn�m p��sp�vku news:%238f6MHzjKHA.4672(a)TK2MSFTNGP06.phx.gbl... > Petr Danes wrote: >> Most excellent, Bob. Thankyouthankyouthankyou, that's exactly it. May >> I ask where you found this? >> > :-) In my head ... > > I suppose you could find other examples by googling DAO and vbscript, but > really, the key is just initializing the dbengine object. The rest of the > code is pretty much what you would write in vba. For example, I just > copied and pasted the last line I gave you, changing "currentdb" (which is > not available in vbscript) to the "db" (database) variable. > >> And no, it's not anything like you describe. > Good, you're good to go. > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > |