Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VB SQL statement problem

  • 14-05-2004 08:21PM
    #1
    Closed Accounts Posts: 1,152 ✭✭✭


    hey all im having trouble getting this UPDATE SQL statement to execute in VB 6
    Private Sub cmdUpdate_Click()
    Dim strSql As String
    
    strSql = "Update tblCustomer" & "SET CustName = '" & txtName.Text & "' " & " WHERE CustNum = " & txtNum.Text
    
    cn.Execute strSql
    
    End Sub
    

    Any help would be much appreciated

    thanks


Comments

  • Closed Accounts Posts: 302 ✭✭Auburn


    What error does it give?


  • Registered Users, Registered Users 2 Posts: 4,775 ✭✭✭JohnK


    When that string is joined there is no space between tblCustomer and SET. The statement you are sending to the database is "Update tblCustomerSET CustName..." and the database is unable to distinguish between the table name and the command you are passing.

    EDIT: Why do you have the string broken up so much? Why not just use:
    strSql = "Update tblCustomer SET CustName = '" & txtName.Text & "' WHERE CustNum = " & txtNum.text


Advertisement