|
-
Aug 15th, 2001, 12:20 PM
#1
Thread Starter
Junior Member
appending field to recordset
ADO HELP:
Dim rst As New ADODB.Recordset
rst.Fields.Append "xx1", adInteger
rst.Fields.Append "xx2", adChar, 5
rst.Open "test",strcon,adopendynamic,adlockoptimistic,adcmdtable
rst.addnew "xx1","test"
rst.update
get an error on rst.addnew "Item cannot be found in the collection corresponding to the requested name or ordinal."
it seems that the xx1 was not appended.
So how will the fields show up in the database. Can someone give me sample code to append fields to my database.
and
how do you create a mdb database in ADO?
in dao it is simply the createdatabase(path)
in ADO how do you do this?
-
Aug 15th, 2001, 12:25 PM
#2
Hyperactive Member
You can use ADOX to create a DB, here is an example.
VB Code:
Private Sub Command1_Click()
Set cat = New ADOX.Catalog
Set tbl = New ADOX.Table
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
-
Aug 15th, 2001, 01:51 PM
#3
Thread Starter
Junior Member
thanks,
but anybody who can answer my first question using ADO, that is appending fields, also
is there a way to copy a table and contents of one access database and add that table and contents to another database.
in dao it is just using the tableder.connect and tabledef.sourcetablename properties. how can we do this with ado?
again thanks
-
Aug 15th, 2001, 02:03 PM
#4
Hyperactive Member
I remember being part of a thread with same problem last week.
Check out this thread, it may help.
http://www.vbforums.com/showthread.p...threadid=94298
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
|