OLE and DAO Example
Keywords: DAO
Question:
Below is a short sample of Visual Basic initiating communications with DAO. Can you get this to work with WinBatch?Option Explicit Public objDAO As Object Public objWrkSpaces As Object Public objWrkSpace As Object Public objDatabase As Object Sub Main() Set objDAO = CreateObject("DAO.DBEngine.35") Set objWrkSpaces = objDAO.WorkSpaces End SubAnswer:
; Set objDAO = CreateObject("") ; Set objWrkSpaces = objDAO.WorkSpaces objDAO=ObjectOpen("DAO.DBEngine.35") objWrkSpaces = objDAO.WorkSpaces ;ObjectClose(objWrkSpaces ; depends what this is ObjectClose(objDAO)If this is an "in-process" OLE server, then you will need WinBatch 99A.Question (cont'd):
This has to be an in process dll. I get OLE initiation failed error. I'll try it with the newer version of WB.Example #2:
Here's DAO example.Make sure DAO.DBEngine.35 exists on those computers. Maybe try searching the registry for that application object. Search under HKEY_Classes_Root for DAO.DBEngine....
And make sure that version 3.5 (35 above) is installed. Open up the registry editor on the PC and do a search for:
DAO.DBEngine
If it's installed it will show up as: DAO.DBEngine.35
ODBC would've been about 100 lines or so.
dao = objectopen("DAO.DBEngine.35") ws = dao.CreateWorkspace("JetWorkspace", "admin", "") db = ws.OpenDatabase("c:\data\access\skytel paging.mdb") ;rs = db.openrecordset("Message Text") sqlstr = "SELECT PINS.[Pager ID], PINS.[User Name], PINS.PIN, PINS.Group, PINS.[Pager Model], PINS.Other FROM PINS WHERE (((PINS.Group)='WESTERN_REG'));" rs = db.openrecordset(sqlstr) thepin = rs.fields("PIN") theid = rs.fields("Pager Id") thename = rs.fields("User Name") thegroup = rs.fields("Group") while rs.eof == 0 ; rs.edit ; message("Debug", thefield.value) ; thefield.value = "New Value" ; rs.update outline = strcat(theid.value, @crlf, thename.value, @crlf, thepin.value, @crlf, thegroup.value) message("Debug", outline) rs.movenext endwhile objectclose(rs) objectclose(db) objectclose(ws) objectclose(dao) message("Debug", "End of Job") exit
Article ID: W13666Filename: OLE and DAO Example.txt