esafwan
January 18th, 2009, 09:55 AM
This query is returning SQL syntax error.... mysql! its in gambas
Please help!
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
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
Please help!
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
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 = '" &
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