Home > Net >  Update the main table with SqlDataAdapter Update method of circulation and child table, the result c
Update the main table with SqlDataAdapter Update method of circulation and child table, the result c

Time:11-18

Public string SaveMuteData1 (string strDB, DataSet [] ds, string [] strSQL, Hashtable htParm)
{
String STR.
SqlParameter [] sqlParm=new SqlParameter [htParm. Count];
Int j=0;
Foreach (DictionaryEntry DE in htParm)
{
SqlParm [j]=new SqlParameter (DE. Key. The ToString (), DE, Value);
j++;
}
SqlConnection con=new SqlConnection (enclosing GetConStr (strDB));
Int intCnt=ds. Length;
Con. The Open ();
SqlTransaction tran=con. BeginTransaction ();
Try
{
for (int i=0; i {
SqlCommand myComm=new SqlCommand {
The Connection=con,
The Transaction=tran,
CommandText strSQL=[I]
};
MyComm. The Parameters. AddWithValue (sqlParm [0]. ParameterName, sqlParm [0], Value);
MyComm.Com mandTimeout=0;
SqlDataAdapter myAdt=new SqlDataAdapter {
SelectCommand=myComm
};
SqlCommandBuilder bd=new SqlCommandBuilder (myAdt);
MyAdt. Update (ds [I]);
MyComm. The Dispose ();
}
Tran.Com MIT ();
STR="";
}
The catch (Exception ex)
{
Tran. The Rollback ();
STR=ex. The Message;
}
The finally
{
Tran. The Dispose ();
}
return str;
}

CodePudding user response:

You are not a trycatch, isn't it application error rolled back, and then you put capture error in STR, and then you didn't see the STR?

CodePudding user response:

No error, code execution, and then looked at the backstage database, the main table data is not, has the child table data
  •  Tags:  
  • C#
  • Related