mahesh waghela

mahesh waghela

  • NA
  • 93
  • 112.9k

Multiple Sql Insert String And RollBack With Catch(Exception)

Jul 30 2011 8:03 AM

If I have to insert with two sql table and the place of string is as below:

// Single Record Insert
String  AA
="Insert into aa(date)values(@date)";

//Multiple Record Insert with datagridview1
For(int i=0;i<datagridview1.rows.count-1;i++)
{
String BB
= "insert into bb(name,amount)values(@name,@amount)";
}

If there are two different strings of sql insert as per as above by single and multiple insert on Button click Event than Is it possible to handle it on single sql command if yes than reply how?.

But as per I think it is not possible by single SqlCommand and if it is true than there are very big problem to adjust SqlTransaction Class for Rollback and Commit. with try and catch block of the EventHandller

I am really struggling to insert multiple sql statement as above at one Button1_Click Event. Suggest me proper solution or proper way , technique.


Answers (5)