|
-
Apr 16th, 2001, 12:39 AM
#1
Thread Starter
Addicted Member
How do i, using ADO create an Access database (which doesnt exist) to hold my tables etc? Please help!
-
Apr 16th, 2001, 12:57 AM
#2
I know how to do it in DAO and then you could connect and use it with ADO. Will that work?
Here is a little sample you can post again or use the help to look up the functions for further explanation.
Code:
Dim newdb As Database
Set newdb = CreateDatabase(PassStr, dbLangGeneral)
'make agencies table
Dim tbAgn As TableDef
Dim IndAgn As Index
Set tbAgn = newdb.CreateTableDef("Agencies")
tbAgn.Indexes.Refresh
tbAgn.Fields.Append tbAgn.CreateField("db_ID", dbLong, 4)
tbAgn.Fields(0).Attributes = dbAutoIncrField
tbAgn.Fields.Append tbAgn.CreateField("Agency", dbText, 50)
tbAgn.Fields.Append tbAgn.CreateField("Path", dbMemo)
tbAgn.Fields.Append tbAgn.CreateField("Access", dbInteger, 2)
tbAgn.Fields.Append tbAgn.CreateField("Notes", dbMemo)
Set IndAgn = tbAgn.CreateIndex("db_ID")
IndAgn.Name = "db_Index"
IndAgn.Primary = True
IndAgn.Fields.Append IndAgn.CreateField("db_ID", dbLong, 4)
tbAgn.Indexes.Append IndAgn
newdb.TableDefs.Append tbAgn
'make settings table
Dim tbSet As TableDef
Dim IndSet As Index
Set tbSet = newdb.CreateTableDef("Settings")
tbSet.Indexes.Refresh
tbSet.Fields.Append tbSet.CreateField("ID", dbLong, 4)
tbSet.Fields(0).Attributes = dbAutoIncrField
tbSet.Fields.Append tbSet.CreateField("HelpMode", dbBoolean)
tbSet.Fields.Append tbSet.CreateField("FileOverride", dbBoolean)
tbSet.Fields.Append tbSet.CreateField("PrintingPrompt", dbBoolean)
tbSet.Fields.Append tbSet.CreateField("Nurses_Read Only", dbBoolean)
tbSet.Fields.Append tbSet.CreateField("Patient_Read Only", dbBoolean)
tbSet.Fields.Append tbSet.CreateField("SearchCommon", dbLong, 4)
tbSet.Fields.Append tbSet.CreateField("SingleAgency", dbBoolean)
Set IndSet = tbSet.CreateIndex("ID")
IndSet.Name = "ID_Index"
IndSet.Primary = True
IndSet.Fields.Append IndSet.CreateField("ID", dbLong, 4)
tbSet.Indexes.Append IndSet
newdb.TableDefs.Append tbSet
'make UserInfo table
Dim tbUsr As TableDef
Dim IndUsr As Index
Set tbUsr = newdb.CreateTableDef("UserInfo")
tbUsr.Indexes.Refresh
tbUsr.Fields.Append tbUsr.CreateField("ID", dbLong, 4)
tbUsr.Fields(0).Attributes = dbAutoIncrField
tbUsr.Fields.Append tbUsr.CreateField("UserName", dbText, 50)
tbUsr.Fields.Append tbUsr.CreateField("UserPassword", dbText, 50)
tbUsr.Fields.Append tbUsr.CreateField("Admin Rights", dbBoolean)
tbUsr.Fields.Append tbUsr.CreateField("Secure Lvl", dbInteger, 2)
Set IndUsr = tbUsr.CreateIndex("ID")
IndUsr.Name = "Usr_Index"
IndUsr.Primary = True
IndUsr.Fields.Append IndUsr.CreateField("ID", dbLong, 4)
tbUsr.Indexes.Append IndUsr
newdb.TableDefs.Append tbUsr
'add relation here
'make User_List table
Dim tbLst As TableDef
Set tbLst = newdb.CreateTableDef("User_List")
tbLst.Fields.Append tbLst.CreateField("db_ID", dbLong, 4)
tbLst.Fields.Append tbLst.CreateField("ID", dbLong, 4)
newdb.TableDefs.Append tbLst
Screen.MousePointer = 0
MsgBox "Common database created", vbInformation, "Common"
PassStr = fs.GetParentFolderName(cDlg.FileName)
Unload Me
Set tbLst = Nothing
Set tbUsr = Nothing
Set tbSet = Nothing
Set tbAgn = Nothing
Set IndUsr = Nothing
Set IndSet = Nothing
Set IndAgn = Nothing
Set newdb = Nothing
Its kind long but it show how to make a simple db and table.
-
Apr 16th, 2001, 01:01 AM
#3
Thread Starter
Addicted Member
create database
i know how to do it using DAO but i need to know how to do it using ADO..
Help! Please...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|