Results 1 to 6 of 6

Thread: [RESOLVED] Append table to ADO database

Threaded View

  1. #1

    Thread Starter
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Resolved [RESOLVED] Append table to ADO database

    I'm a complete dummy when it comes to databases, so I thought I'd try out the simple ADO database code recommended by ChrisE in this VB.Net forum thread (post #48). It creates an .mdb file successfully but fails when I try to append a Table.
    Code:
    Imports ADOX
    [....]
           'create a connection string
            Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbFileName
    
            'replace existing file if any
            IO.File.Delete(mdbFileName)
    
            'create catalog
            Dim cat As New Catalog()
            cat.Create(connectionString)
    
            'create a table with columns
            Dim tbl1 As New Table
            tbl1.Columns.Append("col1", DataTypeEnum.adInteger, 4)
            tbl1.Columns.Append("col2", DataTypeEnum.adLongVarWChar, 255)
    
            'add the table to the tables collection
            Dim obj As Object = DirectCast(tbl1, Object)
            cat.Tables.Append(obj)
    The Append statement in the last line always throws an exception:
    System.Runtime.InteropServices.COMException: 'Table ID is invalid.'
    even when I comment out one or both columns. Can anyone tell me what is going wrong here?

    BB

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