
Hi !
If i got you correctly then I think you are asking, how store data to different tables at in a single event like a button click.
Although you can do it by a 2 different insert statements inside that event but, I suggest you to use a stored procedure.
Write 2 different insert statement for the 2 tables and keep all these in a single stored procedure. Now call that stored procedure on submit button click.
But if these datas are inter-dependent then you have to use transaction with exception handling.
If you are using SQL Server then your stored procedure should look like -
CREATE PROC [dbo].[spInstAllValues]
(
@txt1 NVARCHAR(100), --textbox1 value
@txt2 NVARCHAR(100), --textbox2 value
@rbtn1 NVARCHAR(100), --radiobtn1 value || if your field is nvarchar(100) in database
@rbtn2 NVARCHAR(100) --radiobtn2 value
)
AS
BEGIN
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO txtTable VALUES(@txt1,@txt2)
INSERT INTO radioTable VALUES(@rbtn1,@rbtn2)
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
END
you can learn sql server transaction from following links-
http://www.sqlteam.com/article/introduction-to-transactions
http://www.codeproject.com/KB/database/sqlservertransactions.aspx
If I am missing something then plz reply..
Self-innovator, if this helps please login to Mark As Answer. | Alert Moderator