100分马上给(只要给关于缓存的代码,就是同时向表插入多条记录)在线等急。。。。。。。。。 我没有源码,不过我可以说下我的思路。你可以先在DataSet里增加记录(具体操作你查下吧,很好查),然后提交给数据库,利用DataSet的updatecommand语句。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //给产品表填充记录; OleDbCommand instcommand=new OleDbCommand("insert into p_product(productcode,productname,positioncode,basicprice,timeunit,productnum,description,isoffline) values(@productcode,@productname,@positioncode,@basicprice,@timeunit,@productnum,@description,@isoffline)",con);// instcommand.Transaction=myTrans; instcommand.Parameters.Add("@productcode",OleDbType.VarChar,50); instcommand.Parameters.Add("@productname",OleDbType.VarChar,40); instcommand.Parameters.Add("@positioncode",OleDbType.VarChar,30); instcommand.Parameters.Add("@basicprice",OleDbType.Numeric,5); instcommand.Parameters.Add("@timeunit",OleDbType.Char,4); instcommand.Parameters.Add("@productnum",OleDbType.Integer,4); instcommand.Parameters.Add("@description",OleDbType.VarChar,300); instcommand.Parameters.Add("@isoffline",OleDbType.Char,2); instcommand.Parameters["@productcode"].Value=productid; instcommand.Parameters["@productname"].Value=productname; instcommand.Parameters["@positioncode"].Value=positionpode; instcommand.Parameters["@basicprice"].Value=basicprice; instcommand.Parameters["@productnum"].Value=productnum; instcommand.Parameters["@description"].Value=description; instcommand.Parameters["@isoffline"].Value=isoffline; instcommand.Parameters["@timeunit"].Value=timeunit; //插入到属性表中; adapter=new OleDbDataAdapter("select * from p_properties",con); mydataset=new DataSet(); adapter.Fill(mydataset,"p_properties"); mytable=mydataset.Tables["p_properties"]; int forsize1=list.Count; for(int i=0;i<forsize1;i++) { myrow=mytable.NewRow(); myrow["productcode"]=productid; myrow["propertiescode"]=list[i].ToString(); mytable.Rows.Add(myrow); } OleDbCommandBuilder builder=new OleDbCommandBuilder(adapter); adapter.Update(mydataset,"p_properties"); if(con.State==ConnectionState.Closed) con.Open(); instcommand.ExecuteNonQuery(); // myTrans.Commit(); instcommand.Connection.Close(); 主要是我的事务不能加上去这,插入属性表的记录我是行从数据库中拿出来的,放到数据集中,这个事务搞不定,所以我就问用DataSet怎样做, 使用apdater数据读取器,然后填充dataset,注意dataset做成public变量,不要释放然后更新之后调用 数据读取器的update方法 / . ' / .- . . .- .- ./ .--... .-------- 0 .-- / ....... ' .. '........ ---- . --.. . .---.. - 分 o . ' -. 分 / ' / ' ' ' \-分--/....... . ' ' ' ' \ __/ - - -' ' ' ' ' ' ' ' o ' ' ' ' ' ' ' -..'.----------. I ---------- /////////. 输出文件乱码 如何在C#写的WINDOWS服务中,使线程在固定的时间运行? 查询,charindex相关,一句sql语句 用户登录出现问题! 求助SPREAD 怎么建立一个内存graphics画好一个图片再拷到你的窗口画面? 我是新手,想问一个关于数组(或字符串)中包含另一数组(或字符串)的问题 winform窗体语言问题,窗体属性中language没有缅甸语,怎么办? treeview简单的不能简单的问题! 我要疯了,救救我啊,各位兄弟!!!我他妈的有多少分送多少分!!! 能否用openFileDialog控件新建一个文件 分不够,我再加!!!C#图形编程高手请进!!!
OleDbCommand instcommand=new OleDbCommand("insert into p_product(productcode,productname,positioncode,basicprice,timeunit,productnum,description,isoffline) values(@productcode,@productname,@positioncode,@basicprice,@timeunit,@productnum,@description,@isoffline)",con);
// instcommand.Transaction=myTrans;
instcommand.Parameters.Add("@productcode",OleDbType.VarChar,50);
instcommand.Parameters.Add("@productname",OleDbType.VarChar,40);
instcommand.Parameters.Add("@positioncode",OleDbType.VarChar,30);
instcommand.Parameters.Add("@basicprice",OleDbType.Numeric,5);
instcommand.Parameters.Add("@timeunit",OleDbType.Char,4);
instcommand.Parameters.Add("@productnum",OleDbType.Integer,4);
instcommand.Parameters.Add("@description",OleDbType.VarChar,300);
instcommand.Parameters.Add("@isoffline",OleDbType.Char,2); instcommand.Parameters["@productcode"].Value=productid;
instcommand.Parameters["@productname"].Value=productname;
instcommand.Parameters["@positioncode"].Value=positionpode;
instcommand.Parameters["@basicprice"].Value=basicprice;
instcommand.Parameters["@productnum"].Value=productnum;
instcommand.Parameters["@description"].Value=description;
instcommand.Parameters["@isoffline"].Value=isoffline;
instcommand.Parameters["@timeunit"].Value=timeunit;
//插入到属性表中;
adapter=new OleDbDataAdapter("select * from p_properties",con);
mydataset=new DataSet();
adapter.Fill(mydataset,"p_properties");
mytable=mydataset.Tables["p_properties"];
int forsize1=list.Count;
for(int i=0;i<forsize1;i++)
{
myrow=mytable.NewRow();
myrow["productcode"]=productid;
myrow["propertiescode"]=list[i].ToString();
mytable.Rows.Add(myrow);
}
OleDbCommandBuilder builder=new OleDbCommandBuilder(adapter);
adapter.Update(mydataset,"p_properties");
if(con.State==ConnectionState.Closed)
con.Open();
instcommand.ExecuteNonQuery();
// myTrans.Commit();
instcommand.Connection.Close();
主要是我的事务不能加上去这,插入属性表的记录我是行从数据库中拿出来的,放到数据集中,这个事务搞不定,所以我就问用DataSet怎样做,
' / .- .
. .- .-
./ .--...
.-------- 0 .--
/ .......
' ..
'........ ----
. --..
. .---.. -
分 o . ' -.
分 / '
/ ' ' '
\-分--/....... . ' ' ' '
\ __/ - - -' ' ' '
' ' ' '
o ' ' ' '
' ' '
-..'.----------.
I ----------
/////////.