100分马上给(只要给关于缓存的代码,就是同时向表插入多条记录)在线等急。。。。。。。。。
就是用一个缓存来存储多条记录一次性向数据表提交(插入)最好是用DataSet数据集,最好给代码,一但用上马上给分; 问题点数:0、回复次数:8Top
1 楼DataSet1(共商大计)回复于 2004-08-04 10:21:01 得分 0
foreachTop
2 楼lglesias(因为帅判十年)回复于 2004-08-04 10:23:45 得分 0
帮你顶!!!!!!Top
3 楼mymailyy()回复于 2004-08-05 13:24:07 得分 0
不会吧,就没有一个高手能帮我,天呀,。。。。。。。Top
4 楼mymailyy()回复于 2004-08-05 13:25:51 得分 0
难到这个问题很难呀,我的天,做好事呀,不就是一个缓存呀,有那样夸张吗?Top
5 楼jkflyfox(飞狐)回复于 2004-08-05 17:58:49 得分 0
我没有源码,不过我可以说下我的思路。
你可以先在DataSet里增加记录(具体操作你查下吧,很好查),然后提交给数据库,利用DataSet的updatecommand语句。Top
6 楼mymailyy()回复于 2004-08-06 12:06:16 得分 0
//给产品表填充记录;
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怎样做,Top
7 楼wagod(飞天小神猪.net)回复于 2004-08-06 15:13:28 得分 0
使用apdater数据读取器,然后填充dataset,注意dataset做成public变量,不要释放
然后更新之后调用 数据读取器的update方法Top
8 楼csq0516(阿松)回复于 2004-08-06 22:07:15 得分 0
/ .
' / .- .
. .- .-
./ .--...
.-------- 0 .--
/ .......
' ..
'........ ----
. --..
. .---.. -
分 o . ' -.
分 / '
/ ' ' '
\-分--/....... . ' ' ' '
\ __/ - - -' ' ' '
' ' ' '
o ' ' ' '
' ' '
-..'.----------.
I ----------
/////////.
Top




