Results 1 to 2 of 2

Thread: [RESOLVED] [2005] Adding Table To Existing Access DB.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Resolved [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:
    1. Public Const strAccessConn As String = _
    2.             "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    3.             "Data Source=.\DBName.mdb;" & _
    4.             "Persist Security Info=False"
    5.  
    6. Imports ADOX
    7.  
    8. Public Sub addTablesToDatabase()
    9.         Dim ADOXCatalog As New ADOX.Catalog
    10.         Dim ADOXtable As New Table
    11.         Try
    12.             'Connect To The Database
    13.             ADOXCatalog.ActiveConnection = strAccessConn
    14.             ADOXtable.Name = "tblCustomers"
    15.             ADOXtable.Columns.Append("First_Name", ADOX.DataTypeEnum.adVarWChar, 40)
    16.             'ADOXtable.Columns.Append("customerID", ADOX.DataTypeEnum.adInteger)
    17.             'ADOXtable.Columns.Append("Address", ADOX.DataTypeEnum.adVarWChar, 20)
    18.             'append tables to database
    19.             ADOXCatalog.Tables.Append(ADOXtable)
    20.         Catch ex As Exception
    21.             MessageBox.Show("Error:" & ex.Message)
    22.         Finally
    23.             ADOXtable = Nothing
    24.             ADOXCatalog = Nothing
    25.         End Try
    26.     End Sub

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    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
  •  



Click Here to Expand Forum to Full Width