Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
All I need to do is open an Access database ("dvd.mdb"), remove a record from a table ("TblDVD") where the fieldname ("Title") matches a variable I have, and then close the database.
The machine doesn't have Access installed, but it does have DAO.DBEngine.35 referenced in the registry.
I found this line in the Tech Database, but I'm not sure how to set up the supporting code:
db.execute ("delete from [table] where [field] = 'xyz'")Suggestions?
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/MDAC+MDAC~Installation~Details.txt To begin with try searching our tech support database for the keywords "ADO" or "DAO", you'll find lots of sample code.
You code might look something like this:
; DAO is similar to MS Access Basic... MDBfile = "c:\data\access\survey template.mdb" objdao = ObjectOpen("DAO.DBEngine.35") ;<-- you may have to change for your version objws = objdao.CreateWorkspace("JetWorkspace", "admin", "") objdb = objws.OpenDatabase( MDBfile ) sqlstr = "" ;<-- create the delete SQL statement... objdb.execute(sqlstr) ;<-- execute it... ObjectClose(objdb) ObjectClose(objws) ObjectClose(objdao) Message("Debug", "End of Job") ExitReferenced article:
dao = objectopen("DAO.DBEngine.36") ws = dao.CreateWorkspace("JetWorkspace", "admin", "") db = ws.opendatabase("c:\db1.mdb") db.execute ("delete from [table1] where [name] = 'test1'") objectclose(db) objectclose(ws) objectclose(dao) message("Debug", "End of Job") exitMy next challenge is to open the .mdb file and read the contents of a field into either an array or out to a text file that I can then easily manipulate in Winbatch. I was looking at a "SELECT * INTO..." type command, but I can't find enough information to get it to work. I need to either dump the entire contents of the field to a text file or the code to loop through each record value and copy it to an array.
Where can I get more information on the DAO object structure? I'm not having much luck at the Microsoft site. I hate having to ask these dumb questions.
Click Modules under Objects, and then click New.
In the Visual Basic Editor, click References on the Tools menu.
Scroll through the list until you find Microsoft DAO 3.6 Object Library, and then click to select the reference.
Click OK.
You should now be able to search the DAO object model.
Article ID: W16601
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38