存儲(chǔ)過(guò)程配合UpdateDaset方法批量插入Dataset數(shù)據(jù)實(shí)現(xiàn)代碼
更新時(shí)間:2013年02月24日 14:33:02 作者:
用存儲(chǔ)過(guò)程配合UpdateDaset方法批量插入Dataset數(shù)據(jù),感興趣的你可不要錯(cuò)過(guò)了哈,希望本文提供知識(shí)點(diǎn)可以幫助到你
復(fù)制代碼 代碼如下:
public bool SaveSMSMessage(SMSBatch smsBatch, DataSet smsMessages)
{
//using (TransactionScope ts = new TransactionScope(TransactionScopeOption.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;
}
相關(guān)文章
c語(yǔ)言http請(qǐng)求解析表單內(nèi)容
c語(yǔ)言解析http請(qǐng)求表單內(nèi)容,基于C語(yǔ)言的CGI開(kāi)發(fā),大家參考使用吧2013-12-12Mysql用戶(hù)忘記密碼及密碼過(guò)期問(wèn)題的處理方法
這篇文章主要介紹了 Mysql用戶(hù)忘記密碼及密碼過(guò)期問(wèn)題的處理方法,分步驟給大家介紹的非常詳細(xì),需要的朋友參考下2017-01-01SQL中字段自增(IDENTITY,序列Sequence)的兩種方法
本文主要介紹了SQL中字段自增,主要包括IDENTITY,序列Sequence的兩種方法,具有一定的參考價(jià)值,感興趣的可以了解一下2023-11-11SQL學(xué)習(xí)筆記二 創(chuàng)建表、插入數(shù)據(jù)的語(yǔ)句
SQL學(xué)習(xí)筆記二 創(chuàng)建表、插入數(shù)據(jù)的語(yǔ)句,需要的朋友可以參考下。2011-08-08SQL基礎(chǔ)查詢(xún)和LINQ集成化查詢(xún)
本文詳細(xì)講解了SQL基礎(chǔ)查詢(xún)和LINQ集成化查詢(xún),文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-01-01navicat導(dǎo)入sql數(shù)據(jù)庫(kù)文件的簡(jiǎn)單實(shí)現(xiàn)
在很多項(xiàng)目當(dāng)中都有sql文件導(dǎo)入到MySQL數(shù)據(jù)庫(kù)的需要,因?yàn)橛衧ql數(shù)據(jù)庫(kù)文件,這個(gè)項(xiàng)目才能正常運(yùn)行起來(lái),本文主要介紹了navicat導(dǎo)入sql數(shù)據(jù)庫(kù)文件的簡(jiǎn)單實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2023-11-11