Asp and MS-SQL

Now, I need to update several tables to MS-SQL after after users submitting a form. I can write three sql statements to do this, but I'm afraid the user may stop the process in the process or a table got an error.

Besides writing a stored procedure, what other methods can I do this? How about using the batch mode? I'm not sure about this. Thank you!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Your fears are groundless.

When the user submits a form you asp page will be triggered and will continue until it has finished. If the user hits the stop button all that happens is that the connection is closed but the process on you server will not be interrupted and will complete even though any output will be discarded. (In fact at times many people wish this weren't the case).

The sole exception to this is if you are using RDO from the client to access the database. In which case using a stored procedure would probably be your best bet.

If you are worried that an error in processing one of the statements will cause problems if the other are or are not processed then you have two choices really.

The first is that you check for errors following each statement using the on error clause and take the appropriate action when this is triggered.

Alternatively you can use the batch mode as you suggested.
To do this you will need to call the begintrans method of the connection object. When you are happy with the results you should call the committrans method and if an error occurs call the rollbackreans method.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mscprojAuthor Commented:
Thanks! I get it!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.