I am trying to write an SQL INSERT INTO statement to insert data into a table in MS Access. The method I am writing is accepting an object and then getting the specific information needed to insert into the database out of the object. I have having trouble with the wording of the SQL statement itself and I would appreciate any help. int qID String qText boolean qType int qCorrect sql = "INSERT INTO Question(qID, qText, qType, qCorrect) VALUES(+qID, +"qText", + qType, + qCorrect)");
I also need to write an UPDATE statment based on the same idea, where the method will be sent an object. Could someone give me an example of how the sql statement will look? Thanx again!!!
Adrian Yan
Ranch Hand
Joined: Oct 02, 2000
Posts: 688
posted
0
If you run this command alot, I recommend you to use PreparedStatement, which is alot cleaner. [ October 15, 2003: Message edited by: Adrian Yan ]
Kassi Hill
Greenhorn
Joined: Sep 29, 2003
Posts: 24
posted
0
Thank you VERY much, this appears to have solved my problem. Would the update statement be the same excet using UPDATE instead of INSERT INTO??
Prasma Kankut
Greenhorn
Joined: Oct 15, 2003
Posts: 21
posted
0
Originally posted by Kassi Hill: Would the update statement be the same excet using UPDATE instead of INSERT INTO??
No. The UPDATE query will look like this UPDATE table_name SET column_name = value Be sure to add a WHERE clause, so that only the corresponding row(s) will be updated. Else you will end up updating all the rows in the table. The syntax will be UPDATE table_name SET column_name = value WHERE condition [ October 15, 2003: Message edited by: Prasma Kankut ]
<i>The fact that today we know more than yesterday is good news about today, not bad news about yesterday - Ilja Preuss</i>
Kassi Hill
Greenhorn
Joined: Sep 29, 2003
Posts: 24
posted
0
Thanx again for your help. If I understand correctly, my Upate statement should look something like: