Simple Database Question If you know SQL please help!
Posted: Sun Jul 07, 2013 3:35 pm
So all im trying to do is add a row to a database in SQL. I have searched many websites for correct SQL syntax and have tried many things but I feel like there is some key or some small thing that I am missing. Lets see if you guys can help me out here. Any tips or tricks would be much appreciated. Thank you.
Here is a copy of my code:
here is the sql command
INSERT into Contacts (ID,FirstName,image) VALUES (1,'dfgh','images/defaultpicdkblu.png') WHERE id=1
and here is the error
stack "Contacto Listo 2": execution error at line n/a (External handler: exception) near "revdberr,syntax error"
Here is a copy of my code:
Code: Select all
on DBCreateTable
## Add a tasks table to the database
put GetColumns() into tTableExists
if tTableExists is not empty then
exit DBCreateTable
else
put "CREATE TABLE Contacts(ID SMALLINT(2000), NamePrefix CHAR(20), FirstName CHAR(50)," & \
"MiddleName CHAR(50), LastName CHAR(50), NameSuffix CHAR(20), Phone TINYINT(20)," & \
"PhoneHome TINYINT(20), PhoneWork TINYINT(20), PhoneExtra1 TINYINT(20), PhoneExtra2 " & \
"TINYINT(20), Email CHAR(100), City CHAR(50), State CHAR(50), Country CHAR(50), Birthdate " & \
"CHAR(10), FishType CHAR(50), image CHAR(500), SortList CHAR(100), Notes TEXT, FORM TEXT, NCDART TEXT);"\
into tSQL
revExecuteSQL the cDatabaseID of me, tSQL
-- check the result and display the data or an error message
put revDataFromQuery(tab, cr, the cDatabaseID of me, tSQL) into tData
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
answer "(Developers note: New Database Table Created)"
end if
end if
end DBCreateTable
on AddContact pContactID, pTitle, pic
## Build and execute the SQL insert statement
##THIS NEEDS TO BE UPDATED FOR THE NEW DATABASE!!!!
put "INSERT into Contacts (ID,FirstName,image) VALUES (" & pContactID & ",'" & pTitle & "','" & pic & "') " into tSQL
put "WHERE id="& pContactID & "" after tSQL
revExecuteSQL (the cDatabaseID of me, tSQL)
end AddContact
INSERT into Contacts (ID,FirstName,image) VALUES (1,'dfgh','images/defaultpicdkblu.png') WHERE id=1
and here is the error
stack "Contacto Listo 2": execution error at line n/a (External handler: exception) near "revdberr,syntax error"