Results 1 to 5 of 5

Thread: Adding a table

  1. #1

    Thread Starter
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565

    Question

    I'm trying to create a table in Access via VB using ADO.

    I keep getting the error message :

    3251 - Object or provider is not capable of performing requested operation.

    This is the code I'm using ...

    Code:
    Dim cat As New ADOX.Catalog
    Dim tbl As New ADOX.Table
    
    cat.ActiveConnection = conCrowd
    
    With tbl
    
      .Name = "TempTable"
    
      .Columns.Append "Field1", adVarWChar
      .Columns.Append "Field2", adVarWChar
      .Columns.Append "Field3", adVarWChar
    
    End With
    
    cat.Tables.Append tbl
    
    Set cat = Nothing
    Can somebody tell me whats going on?
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  2. #2
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    ADOX ?

    Stevie -

    What library is ADOX ?
    That's Mr Mullet to you, you mulletless wonder.

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    This works fine for me....I'm using the Jet 4.0 provider with an Access 2000 DB, but you're probably using 3.51......(which is probably why it won't work for you)

    Code:
        Dim objCn As ADODB.Connection
        Dim objCat As ADOX.Catalog
        Dim objTbl As ADOX.Table
        
        Set objCat = New ADOX.Catalog
        Set objCn = New ADODB.Connection
        Set objTbl = New Table
        
        objCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Nwind2k.mdb"
        
        objCat.ActiveConnection = objCn
    
        With objTbl
        
          .Name = "TempTable"
        
          .Columns.Append "Field1", adVarWChar
          .Columns.Append "Field2", adVarWChar
          .Columns.Append "Field3", adVarWChar
        
        End With
        
        objCat.Tables.Append objTbl
        
        Set objCat = Nothing

  4. #4
    Guest
    it is a little easier with sql, try it...

    db.Execute "CREATE TABLE MyTable " _
    & "(Field1 TEXT(50) , Field2 TEXT(50) , " _
    & "Field3 TEXT(50));"



  5. #5

    Thread Starter
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Cheers for all the answers, I wasn't in work yesterday afternoon so I didn't get to see all the replies.

    In the end I did it with a SQL statement instead of with ADO much like the Larryn's answer.

    Thanks again.
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

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