我没有源码,不过我可以说下我的思路。
你可以先在DataSet里增加记录(具体操作你查下吧,很好查),然后提交给数据库,利用DataSet的updatecommand语句。

解决方案 »

  1.   

    //给产品表填充记录;
                    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怎样做,
      

  2.   

    使用apdater数据读取器,然后填充dataset,注意dataset做成public变量,不要释放然后更新之后调用 数据读取器的update方法
      

  3.   

    /   .
                                                              ' /  .- .
                                                              .  .- .-
                                                            ./    .--...
                                                  .-------- 0    .--
                                                 /                 .......
                                                '                  ..
                                                 '........            ----
                                                          .          --..
                                                           .   .---..   -
                                       分  o               .  '     -.
                                         分               /   '
                                                         / ' ' '
                                       \-分--/....... . '  ' '  '
                                        \ __/ -      - -'  '  ' '
                                                        '  '  ' '
                                         o              '   ' ' '
                                                        '   '  '
                                                         -..'.----------.
                                                            I   ----------
                                                     /////////.