Results 1 to 3 of 3

Thread: ADO Help

  1. #1

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Angry

    Dear All

    I am having a few problems creating tables using ADO

    I get the following error -2147217900 : Syntax error in field definition.

    here is the code to create the database
    Code:
        '\\Create Database
        adoCat.Create ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & App.Path & "\LogFileCheck.mdb;")
    The database creation works fine

    It is when I try to create a table as follows

    Code:
    Public Function bfn_ADOCreateTable(ByVal sSQL As String) As Boolean
    On Error GoTo ErrErrADOCreateTable
        
        cn.Open adoCat.ActiveConnection '\\Set the connection
        cn.Execute sSQL
        bfn_ADOCreateTable = True    '\\Table creation successful
    
    Exit_ErrADOCreateTable:    '\\Exit routine
        Exit Function
        
    ErrErrADOCreateTable: '\\Error Routine
        Select Case Err
            Case Err
                For Each objErr In cn.Errors    '\\Check errors in ADO
                    If strError = "" Then
                        strError = objErr.Number
                        strError = strError & " : " & objErr.Description
                    Else
                        strError = strError & vbCrLf
                        strError = objErr.Number
                        strError = strError & " : " & objErr.Description
                    End If
                Next
                            
                If strError = "" Then   '\\Check general errors
                    strError = Err.Number & " : " & Err.Description
                End If
                
                Err.Clear
                cn.Errors.Clear
                bfn_ADOCreateTable = False     '\\Table creation failed
                Resume Exit_ErrADOCreateTable
        End Select
    End Function
    This is the point the error occurs. The error occurs on the
    Code:
        cn.Execute sSQL
    part of the code in the table creation function.

    The SQL is as follows
    Code:
    CREATE TABLE tblHeader (ID AUTOINCREMENT CONSTRAINT HeaderID PRIMARY KEY, type INTEGER,flags INTEGER,modifiers INTEGER,till INTEGER,seqno INTEGER,when INTEGER,oper INTEGER,trans INTEGER);
    I have tried to run this SQL by copying the SQL directly into an access query and running it. The table is created with no problems.

    As soon as I run it in VB I get the error.

    Can you help?

    Thanks

    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Post the SQL. That's where the error is.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    Thanks monte96 but I've Sussed it

    I have now precceded all the field names with fld_(field name)
    and it worked.

    One of the fields must have been a reserved word in ADO.
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


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