|
-
Sep 11th, 2001, 02:33 AM
#1
Thread Starter
New Member
Please help me How can i create a new table using ado
I'm a beginner in using ado
My application needs to create a DB at runtime
Can someone give me an example on how to create tables and fields ?
Thank You all & excuse me if my english is bad
-
Sep 11th, 2001, 03:07 AM
#2
-= B u g S l a y e r =-
sample
VB Code:
Option Explicit
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Private Sub Command1_Click()
Set cat = New ADOX.Catalog
Set tbl = New ADOX.Table
' create the db
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\newDB.mdb"
With tbl
.Name = "TestTable"
' Create fields and append them to the
' Columns collection of the new Table object.
With .Columns
.Append "ID COLUMN"
.Append "SetName", adVarWChar, 255
.Append "SetVal", adVarWChar, 255
.Append "Description", adVarWChar, 255
End With
End With
' Add the new Table to the Tables collection of the database.
cat.Tables.Append tbl
Set cat = Nothing
Set tbl = Nothing
End Sub
-
Sep 11th, 2001, 03:12 AM
#3
-= B u g S l a y e r =-
You need to add a reference to 'Microsoft ADO Ext. X.X For DLL And Security' in order to use the sample.
-
Sep 11th, 2001, 03:13 AM
#4
-= B u g S l a y e r =-
You can also create tables using SQL
VB Code:
'add a table with some fields
sql = "CREATE TABLE TestTable (ID COUNTER, SetName TEXT(50), SetVal TEXT(255), Description TEXT(255))"
db.Execute sql
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
|