SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    erro r in insert statement

    this is the query str = "IF EXISTS (SELECT user, country,city FROM table WHERE user='" & txtuser.text & "' AND country='" & txtcountry.text & "' AND city='" & txtcity.text & "')" _ & " UPDATE table(user) set user='" & txtuser.text & "' WHERE country='" & txtcountry.text & "' AND city='" & txtcity.text & "' " _ & " Else " _ & "INSERT INTO table(user) VALUES('" & txtuser.text & "' WHERE country='" & txtcountry.text & "' AND city='" & txtcity.text & "') "

    error
    Line 1: Incorrect syntax near '('. [SqlException (0x80131904): Line 1: Incorrect syntax near '('. Incorrect syntax near the keyword 'WHERE'.]

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2008
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this part look strange
    INSERT INTO table(user) VALUES('" & txtuser.text & "' WHERE country='" & txtcountry.text & "' AND city='" & txtcity.text & "')

    think, it should be like this:
    INSERT INTO table(user) VALUES('" & txtuser.text & "','" & txtcountry.text & "', '" & txtcity.text & "')


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •