Find the answer to your Linux question:
Results 1 to 3 of 3
This query is returning SQL syntax error.... mysql! Please help! Code: sql = "insert into students( 'fname' ,'lname' ,'father' ,'mother' ,'guardian' ,'dob' ,'identity' ,'note1' ,'phone' ,'phone2' ,'mobile' ,'email' ,'address' ,'paddress' ...
  1. #1
    Just Joined! esafwan's Avatar
    Join Date
    Mar 2008
    Location
    Bangalore, India
    Posts
    34

    What is wrong with this sql query?

    This query is returning SQL syntax error.... mysql!
    Please help!
    Code:
     sql = "insert into students( 'fname' ,'lname' ,'father' ,'mother' ,'guardian' ,'dob' ,'identity' ,'note1' ,'phone' ,'phone2' ,'mobile' ,'email' ,'address' ,'paddress' ,'adate' ,'agrade' ,'hobbies' ,'skills' ,'note2' ) values( 'fname' ,'lname' ,'father' ,'mother' ,'guardian' ,'dob' ,'identity' ,'note1' ,'phone' ,'phone2' ,'mobile' ,'email' ,'address' ,'paddress' ,'adate' ,'agrade' ,'hobbies' ,'skills' ,'note2' )"

    the whole block

    Code:
     PUBLIC SUB btnSave_Click()
     
    DIM fname AS String = txtfname.text
    DIM lname AS String = txtlname.text
    DIM father AS String = txtfather.text
    DIM mother AS String = txtmother.text
    DIM guardian AS String = txtguardian.text
    DIM dob AS String = txtdob.text
    DIM identity AS String = txtid.text
    DIM note1 AS String = txtnotes.text
    DIM phone AS String = txtaphone.text
    DIM phone2 AS String = txtaphone.text
    DIM mobile AS String = txtmobile.text
    DIM email AS String = txtemail.text
    DIM address AS String = txtaddress.text
    DIM paddress AS String = txtpaddress.text
    DIM adate AS String = txtadate.text
    DIM agrade AS String = txtagrade.text
    DIM hobbies AS String = txthobbies.text
    DIM skills AS String = txtfname.text
    DIM note2 AS String = txtnotes2.text
     
     
     
      DIM sql AS String
    
      IF btnAdd.Enabled = FALSE THEN
        sql = "insert into students( 'fname' ,'lname' ,'father' ,'mother' ,'guardian' ,'dob' ,'identity' ,'note1' ,'phone' ,'phone2' ,'mobile' ,'email' ,'address' ,'paddress' ,'adate' ,'agrade' ,'hobbies' ,'skills' ,'note2' ) values( 'fname' ,'lname' ,'father' ,'mother' ,'guardian' ,'dob' ,'identity' ,'note1' ,'phone' ,'phone2' ,'mobile' ,'email' ,'address' ,'paddress' ,'adate' ,'agrade' ,'hobbies' ,'skills' ,'note2' )"
    
        MyRS = MyConn.Exec(sql)
        btnAdd.Enabled = TRUE
      ELSE
      
    ''''''''''''''''''''''
    'Updating''''''''''
    ''''''''''''''''''''''
        sql = "update students set "
        sql = sql & "fname = '" &
        fname
        sql = sql & "',lname = '" &
        lname
        sql = sql & "',father = '" &
       father
        sql = sql & "',mother = '" &
        mother
        sql = sql & "',guardian = '" &
        txtguardian.text
        sql = sql & "',dob = '" &
        dob
        
        sql = sql & "',identity = '" &
        identity
        sql = sql & "',note1 = '" &
        txtnotes.text
        sql = sql & "',phone = '" &
        phone
        
        sql = sql & "',phone2 = '" &
        phone2
        sql = sql & "',mobile = '" &
        mobile
        sql = sql & "',email = '" &
        email
        sql = sql & "',address = '" &
       address
        sql = sql & "',paddress = '" &
        paddress
        sql = sql & "',adate = '" &
        adate
        sql = sql & "',agrade = '" &
       agrade
        sql = sql & "',hobbies = '" &
        hobbies
        sql = sql & "',skills = '" &
        skills
         
        sql = sql & "',note2 = '" & note2 & "' where id = " & vCari
        MyRS = MyConn.Exec(sql)
      ENDIF
      getData
      fillUpListBox                                   
    
     CATCH
      Message.Error(Error.Text & "add/update")
     END

  2. #2
    Just Joined! sathiya's Avatar
    Join Date
    Feb 2008
    Location
    Bangalore, India
    Posts
    97
    where is the VALUES keyword in the query ?

  3. #3
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    I don't usually quote the column names or values. I use MS SQL though so I can't be sure.

Posting Permissions

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