CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Question editing listview using change button

    can anybody tell me why i got syntax error(missing operator) in query expression'ID='; here is the code what i have written.any help would be greatly appreciated.
    Code:
    Private Sub Command2_Click()
    If CheckInput = True Then
        Dim success As Boolean
        Set con = New ADODB.Connection
        success = OpenConnection(con)
     If success = False Then
          MsgBox ("Cannot Open Connection")
          Exit Sub
    End If
    Set rs = New ADODB.Recordset
    rs.Open "select * from supplierS where ID=" & Text1.Text, con, adOpenDynamic, adLockOptimistic
     If rs.BOF And rs.EOF Then rs.AddNew
     ' rs.Fields("Supplier_id") = Text1.Text
       rs.Fields("Supplier_name") = Text2.Text
       rs.Fields("contact_person") = Text3.Text
       rs.Fields("contact_no") = Text4.Text
       rs.Fields("office_address") = Text6.Text
       rs.Fields("emails") = Text7.Text
       rs.Fields("website") = Text8.Text
       rs.Fields("Fax_no") = Text5.Text
       rs.Fields("item_type") = Combo1.Text
       rs.Update
       MsgBox ("data saved")
       rs.Close
     Else
       Exit Sub
    End If
    con.Close
    Set con = Nothing
    End Sub
    Last edited by firoz.raj; December 27th, 2009 at 04:15 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: editing listview using change button

    Do the same thing we keep saying in all the other threads. If you paste that into Access, it will tell you the error. (I suspect ID is a reserved word, that you have to change)

    Otherwise, what's in the textbox? If it's a number, then things should work
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: editing listview using change button

    Is this the exact same error again ????

    Could it be that the Supplier_ID is an AUTO_ALLOCATED field which means you cannot allocate a number to it (ever) ???

    It is Auto Allocated by the database when you first add a record

    Only you know the answer as we cannot see your table definitions



    The last few requests for help you have posted are about this exact problem. (You never tell us if this answer solves your problem, but you stop asking when given this answer)

    It will go a long way to help everyone help you, if you put RESOLVED along side your posts where relevant

    Please FIROZ - if what I am telling you is correct, follow these instructions

    1) Put a link to this thread on your desktop
    2) Next time you get a syntax error which has any field name with _ID associated with it, click the link

  4. #4
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Resolved Re: editing listview using change button

    Resolved

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: editing listview using change button

    Quote Originally Posted by firoz.raj View Post
    Resolved

    Go to the FIRST POST, pull down THREAD TOOLS, and mark it as RESOLVED.

    This will change the HEADER so we don't have to scroll to the bottom to see that it's RESOLVED
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: editing listview using change button

    Like this ..... Cheers !
    Attached Images Attached Images  

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

Featured