Results 1 to 5 of 5

Thread: INSERT INTO

  1. #1

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

    This won't work

    Code:
        cnn.BeginTrans
            sSQL = "INSERT INTO tblUsers " _
              & "(User_Name, Password, Group) VALUES ('" & txtUserName & "', '" & txtPassword & "', '" & cboGroup & "');"
            
            cnnMIS.Execute sSQL
        cnn.CommitTrans
    This is what the sSQL string returns

    INSERT INTO tblUsers (User_Name, Password, Group) VALUES ('Gary Lowe', 'newpass', 'Admins')

    The only other field in the table is an ID field which is an auto number, will this have to be added to the sql string.

    The database is access 97 FE = VB6
    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
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    No you should not include the ID if it's an auto numbered field.

    What error message do you get?

    You use a transaction on a connection object called cnn but you execute the SQL statement on a connection object called cnnMIS, could that be the problem?

    Give us some more information and I will be happy to try to answer your question.

    Best regards

  3. #3

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

    The connection objects in the code are all cnnMIS, I was just trying to make it look general.

    The error that keeps coming up is:

    -2147217900
    Syntax error in INSERT INTO statement.

    I can't see anything wrong with the SQL though.
    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


  4. #4

  5. #5

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

    That worked
    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