Is it possible to update two tables using SQL Data Source and ASP.NET Grid View? I have the following SQL Query for the Select statement.
SELECT
tbl_user
Yes, it's possible. Here is how to do it in a safe way:
CREATE PROCEDURE UpdateUser (@ID int, @Pass varchar(15), @Email varchar(75)) AS
BEGIN TRANSACTION
UPDATE tbl_user_login SET Pass = @Pass WHERE ID = @ID
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
UPDATE tbl_user_profile SET Email1 = @Email WHERE ID = @ID
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
COMMIT
In this way you don't need to be worried in case there is some error raised by any of the updates. Which means: If any of them will fail, the whole operation will be canceled and you will not have inconsistent data in your DB.
More about the use of Transactions
here: http://www.4guysfromrolla.com/webtech/080305-1.shtml
The basic DELETE statement is: DELETE FROM