Copy codeThe Code is as follows:
Public bool SaveSMSMessage (SMSBatch smsBatch, DataSet smsMessages)
{
// Using (TransactionScope ts = new TransactionScope (transactionscospontion. Suppress ))
//{
Foreach (DataRow row in smsMessages. Tables [0]. Rows)
Row. SetModified ();
SqlDatabase db = new SqlDatabase (this. ConsultantsConnString );
String sqlCmd = "EXEC cn. SMSSaveSMSMessage @ SMSBatchID, @ SMSTypeID, @ SubsidiaryID, @ ContactID, @ Message, @ PhoneNumber ";
Using (SqlCommand cmd = db. GetSqlStringCommand (sqlCmd) as SqlCommand)
{
Cmd. CommandTimeout = 600;
Cmd. Parameters. AddWithValue ("@ SMSBatchID", smsBatch. SMSBatchID );
Cmd. Parameters. AddWithValue ("@ SMSTypeID", smsBatch. SMSType. SMSTypeID );
Cmd. Parameters. AddWithValue ("@ SubsidiaryID", smsBatch. SMSType. SubsidiaryID );
Db. AddInParameter (cmd, "@ ContactID", DbType. Int64, "ContactID", DataRowVersion. Current );
Db. AddInParameter (cmd, "@ Message", DbType. String, "Message", DataRowVersion. Current );
If (smsMessages. Tables [0]. Columns. Contains ("PhoneNumber "))
{
Db. AddInParameter (cmd, "@ PhoneNumber", DbType. String, "PhoneNumber", DataRowVersion. Current );
}
Else
{
Db. AddInParameter (cmd, "@ PhoneNumber", DbType. String, DBNull. Value );
}
Int rowsEffected = db. UpdateDataSet (smsMessages, "SMSMessage", null, cmd, null, UpdateBehavior. Transactional );
SqlCmd = rowsEffected. ToString ();
}
// Ts. Complete ();
//}
Return true;
}