Click here to Skip to main content
15,918,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem in my aspx page there r 12 fields I want to save first 8 value in table 1 .after saving value getting table 1 auto generating id and save other 4 field to another table2 .and at last table1 id and rest value saving to table 3 how can i do it
Posted
Comments
PJ003 22-Mar-12 10:16am    
Yes, you can insert any number of SQL Commands using SQL Stored Procedure on a single button click.

1 solution

This is very basic ADO.NET coding

using(SqlCommand cmd1 = new SqlCommand("proc name", connection))
{
   cmd1.Paramaters.AddWithValue(...);
   // repeat as necesasry

   cmd1.ExecuteNonQuery();

   int id = (int)cmd1.Paramters["output param name"].Value;
}


Repeat for other inserts.
 
Share this answer
 
Comments
Mohd Shahnawaz Khan 27-Mar-12 10:38am    
how can here i will save table 1 id to table 2
[no name] 27-Mar-12 11:07am    
By picking up a book on ADO.NET and reading it. Seriously, this is a basic skill that you should learn before attempting to work with the tools.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900