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




Reply With Quote