Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Code to Create a Temporary Database

Keywords: 	 temporary database

It's sometimes useful to create a temporary database, perform some queries, to use in conjunction with other portions of a script.

Here's some sample code to do that.

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

dao = objectopen("DAO.DBEngine.35")

;english language
lang = ";LANGID=0x0409;CP=1252;COUNTRY=0"
ver  = 32  ;database version  3.0/3.5 file

ws = dao.CreateWorkspace("JetWorkspace", "admin", "")
db = ws.CreateDatabase("d:\report stage\test.mdb", lang, ver)

; create a table in the new db

tablesql = "create table [Test Table] ([First Name] TEXT (77), [Last Name] TEXT (77), [Amount] LONG, [Comments] MEMO)"
;	execute the table build SQL command...
db.execute(tablesql)

sqlstr = "SELECT count(*) as [cnt] FROM [Test Table];"
db.createquerydef("Test Query", sqlstr)


objectclose(db)
objectclose(ws)
objectclose(dao)

message("Debug", "End of Job")

exit

Article ID:   W14665
Filename:   Code to Create a Temporary DB.txt