Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Update" and "Insert" at the same time in 1 form

Status
Not open for further replies.

damipera

Technical User
Dec 1, 2005
134
GB
Hi guys, I just want to know if it's possible to "Update" and "Insert" at the same time in 1 form using classic asp?

TestTable1
id | isfieldticked | info
-----------------------
1 | Yes | test1
2 | No | test2

for example I want to insert a new record to TestTable1 table and at the same time I want to make the "isfieldticked" field of id=2 to "Yes", how will I be able to do that by just clicking one submit button on one single form?

any ideas?

thnx
 
So you want to update something for the record where id=2 and then you want to insert a new record (presumably where id=3)? There are a couple of ways to handle it. One would be to run two different SQL commands in the same function in your ASP file but that could open up problems. What happens if only one of the two actions occurs but the other fails (and doesn't roll back the other)?

The other would be to create a single transaction in a SQL Stored Procedure and then pass in the values you'd need to process the SP. If a single transaction, either both go or both will fail. That would probably be the best way to handle it.

------------------------------------------------------------------------------------------------------------------------
Reason and free inquiry are the only effectual agents against error; they are the natural enemies of error and of error only.

Thomas Jefferson

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top