|
-
Oct 19th, 2006, 04:28 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Adding Table To Existing Access DB.
Folks, Following pirate's example in the code bank,i am trying to add tables to the existing access database but i am finding some problem and i need help.
The function below gives me an error message.
"Error:Arguments are of the wrong type,are out of acceptable range,or are in conflict with one another".
All the code examples i have seen seem to work when you create an access database(thus opening the connection) then you add tables into it.
But since i have my access database ready, i dont need to use
ADOXcatalog.Create(myConn).
Below is my code
'a reference to ADOX (Microsoft ADO Ext. 2.x for DDL and Security)
VB Code:
Public Const strAccessConn As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=.\DBName.mdb;" & _
"Persist Security Info=False"
Imports ADOX
Public Sub addTablesToDatabase()
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOXtable As New Table
Try
'Connect To The Database
ADOXCatalog.ActiveConnection = strAccessConn
ADOXtable.Name = "tblCustomers"
ADOXtable.Columns.Append("First_Name", ADOX.DataTypeEnum.adVarWChar, 40)
'ADOXtable.Columns.Append("customerID", ADOX.DataTypeEnum.adInteger)
'ADOXtable.Columns.Append("Address", ADOX.DataTypeEnum.adVarWChar, 20)
'append tables to database
ADOXCatalog.Tables.Append(ADOXtable)
Catch ex As Exception
MessageBox.Show("Error:" & ex.Message)
Finally
ADOXtable = Nothing
ADOXCatalog = Nothing
End Try
End Sub
-
Oct 19th, 2006, 04:40 AM
#2
Thread Starter
Hyperactive Member
Re: [2005] Adding Table To Existing Access DB.
Ok. Got it.
I had to use some ADODB.Connection
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
|