insert second time (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Guest -> insert second time (3/15/2001 23:25:00)

i have a tbl_QA: name, questions, answers, date.

on my get_question.asp, i was able to insert name, questions, date sucessfully. (obvious answers aren't available yet)

i also have another page display all the questions for people to answers. once they submit answer, i want this answer to go into the samet table tbl_QA, verything stays the same except now "answers" now has just been filled.

at first i thought, i should do insert but insert gave me another record with everything blanks except answers field.

then i thought about update the current table, but it won't work due to some reasons. my query:
UPDATE tble_QA
SET answers='::answers::'
WHERE id=::id::

please help
thanks





Guest -> RE: insert second time (3/15/2001 13:02:00)

The problem seems to stem from your WHERE clause in that there is no ID field in your tbl_QA. For an UPDATE to statement to occur, you must match the inserted data with existing data in one of the fields. Thus, there reason you are getting a new entry instead of an update is this missing link. I would add another field to the tbl_QA to the effect of QUESTION_NUM which gives a unique number to all the questions submitted to the database. Thus, when a reply is posted to the database, you can update the answer field based on this QUESTION_NUM. You could do this by name if they are unique...and think using the question field wold be too long.

There are many ways to do this...but the key is matching the field to be updated with data from an existing field in the same record.





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875