Results 1 to 5 of 5

Thread: [RESOLVED] update staement

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Resolved [RESOLVED] update staement

    can u plz give me the correct syntax of the update statement below

    VB Code:
    1. ins = "update [data] set [inv] = rs(inv),[add]=rs(add) , pkg=rs(pkg), box=rs(box),lno=textbox6,date=dtp1,lrno=textbox7  "
    Using VB.NET 2003/.NET 1.1

    If you found a post useful then please Rate it!
    Please mark you thread resolved using the Thread Tools above

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: update staement

    I suggest that you read the SQL tutorial in my signature.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member josep's Avatar
    Join Date
    Sep 2006
    Location
    Barcelona
    Posts
    409

    Re: update staement

    Hi,

    You are not building the string correctly
    it should something like

    VB Code:
    1. update [data] set [inv] =" & rs(inv) & ",[add]=" & rs(add) & ", pkg=" & rs(pkg)& ", box=" & rs(box) & ",lno=" & textbox6.text & ",date=" & dtp1 & ",lrno=" & textbox7.text

    I just not insert quotes because I do not know which fields are numeric and which ones are alphanumerics

    But, I strongly do not recomend to do that use parameters, instead of that long statements (check tutorials for ADO.NET to know of it works) Yo can found some of them on my signature

    Hope this helps
    Useful links:DB connection strings ADO.NET VB.NET Tutorials

    • Don't forget to close the thread if solved
    • If this post helps you rate it

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Re: update staement

    all the fields are text (string) except date
    Using VB.NET 2003/.NET 1.1

    If you found a post useful then please Rate it!
    Please mark you thread resolved using the Thread Tools above

  5. #5
    Hyperactive Member josep's Avatar
    Join Date
    Sep 2006
    Location
    Barcelona
    Posts
    409

    Re: update staement

    Then you need to put single quotes

    update [data] set [inv] ='" & rs(inv) & "',[add]='" & rs(add) & "', pkg='" & rs(pkg)& "', box='" & rs(box) & "',lno='" & textbox6.text & "',date=" & dtp1 & ",lrno='" & textbox7.text & "'"
    Useful links:DB connection strings ADO.NET VB.NET Tutorials

    • Don't forget to close the thread if solved
    • If this post helps you rate it

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