悬赏园豆:50
[已关闭问题]
<P>ReturnBoolMessage IGoldIdealDBConn.DeleteOperation(string connectionStr, string selectString, DataSet ds)<BR> {<BR> //定义变量记录执行的结果<BR> ReturnBoolMessage resultFlag = new ReturnBoolMessage();<BR> //数据库连接<BR> SqlConnection conn = new SqlConnection(connectionStr);<BR> //打开连接<BR> conn.Open();<BR> //SqlDataAdapter对象<BR> SqlDataAdapter da = new SqlDataAdapter(selectString, conn);<BR> //SqlCommandBuilder对象<BR> SqlCommandBuilder builder = new SqlCommandBuilder(da);<BR> da.DeleteCommand = builder.GetDeleteCommand();<BR> //事务<BR> SqlTransaction tn = conn.BeginTransaction();<BR> //设置command的事务属性<BR> da.DeleteCommand.Transaction = tn;<BR> //进行表映射<BR> for (int i = 0; i < ds.Tables.Count; i++)<BR> {<BR> if (i == 0)<BR> {<BR> da.TableMappings.Add("Table", ds.Tables[i].TableName);<BR> }<BR> else<BR> {<BR>  
comy
|
初学一级
|
园豆:
150
提问于:2008-03-14 22:41