PDA

Click to See Complete Forum and Search --> : Creating tables in ADO


cyoconnor
Mar 12th, 2000, 08:58 PM
I swear blind I cannot find how to do this from the MSDN.

>Okay, I've managed to create a table as per Clunietp:

Dim strConnectionStringOfNewDB As String
Dim objCat As ADOX.Catalog

Set objCat = New ADOX.Catalog
strConnectionStringOfNewDB = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\db.mdb"
objCat.Create strConnectionStringOfNewDB

Set objCat = Nothing

>Now I try to create a table:

cCN.Provider = "Microsoft.Jet.OLEDB.3.51;"
cCN.Properties("Data Source") = "c:\db.mdb"
cCN.Open

Set cRS = cCN.Execute("CREATE TABLE tblint (anumber TEXT atype TEXT);")

>but it falls over on the SQL!
What am I doing wrong? Perhaps I should have started this app in DAO, but I've come so far I can't let ADO beat me now!

Thanks

CYOCONNOR

Clunietp
Mar 12th, 2000, 10:40 PM
why don't you use the code Chris posted here: http://www.vb-world.net/forums/showthread.php?threadid=10720&pagenumber=2 ??

Anyways, using your method, where are your connection and recordset objects defined? Why are you trying to return a recordset from a CREATE TABLE statement?

To get your way to work, change this line:

CREATE TABLE tblint (anumber TEXT atype TEXT)

To this:

CREATE TABLE tblint (anumber TEXT, atype TEXT)

You forgot the comma.

HTH

Tom

cyoconnor
Mar 13th, 2000, 06:56 AM
Thanks for the help, yet again, Clunietp.
<b>
why don't you use the code Chris posted here: http://www.vb-world.net/forums/showthread.php?threadid=10720&pagenumber=2 ??
</B>
Because the subject header related to setting database passwords, not creating tables, as did the first few posts, which meant I just skipped over it when searching.

I searched the whole forum for answers to this question. Mustn't be searching hard enough!

CYOCONNOR