Click to See Complete Forum and Search --> : ADO


Kathy
November 16th, 1999, 04:07 PM
Hi,

Adding fields to database, if I use the Stand-alone Recordsets, which
appends fields to the Fields collection, and finally open it:

rs.Fields.Append "FirstName" ,adChar,50
rs.Fields.Append "LastName" ,adChar,50
rs.Open

The problem is I do not know how to a associate the added Fields collection
to the "Employees" table I want to create.

I tried: rs.Open "Employees", cnn,adOpenStatic, adLockOptimistic
and get error ---->[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'Employees'. Make sure it exists and that its name is spelled correctly.

Please show me the syntax

Thanks

Warrier
November 18th, 1999, 04:46 PM
You can try using ADOX for which you need to set reference to msadox.dll

Just try the sample for reference.
Sub CreateTable()

Dim tbl As New Table
Dim cat As New ADOX.Catalog

'Open the catalog.
' Open the Catalog.
cat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=dbname;"

tbl.Name = "MyTable"
tbl.Columns.Append "Column1", adInteger
tbl.Columns.Append "Column2", adInteger
tbl.Columns.Append "Column3", adVarWChar, 50
cat.Tables.Append tbl

End Sub

Kathy
November 19th, 1999, 08:31 AM
Thanks for your code.
I really appreciate it.