日期:2014-05-16  浏览次数:20434 次

使用sqlDAdapter.Update()和事务的问题,求解?
if (dsRevData == null)
                return false;
            string TableName =this.GetTableName(ProjectPara);
            string sql = " insert into " + TableName + " (ShippingPoin,Plant,Carrier,Delivery,ItemNum,SSCC,CartonBoxNum,Model,ProductNum,IMEISIM_1,IMEISIM_2,SNNum,CustomerPO,MONum,[SO/STO],BOL,PGIDate)";
            sql +=" values(@ShippingPoin,@Plant,@Carrier,@Delivery,@ItemNum,@SSCC,@CartonBoxNum,@Model,@ProductNum,@IMEISIM_1,@IMEISIM_2,@SNNum,@CustomerPO,@MONum,@SOSTO,@BOL,@PGIDate)";
            
            SqlConnection con = new SqlConnection(GetStrConnection(ProjectPara));
            try
            {
                con.Open();
            }
            catch (Exception ex)
            {
                this.OnError("Error", "ImportData:SqlConnection open", ex.ToString(), true, false);
                return false;
            }
            //SqlTransaction transaction = con.BeginTransaction();
            SqlCommand command = new SqlCommand(sql, con);
            try
            {
                command.Parameters.Add("@ShippingPoin", SqlDbType.VarChar, 20, "ShippingPoin");
                command.Parameters.Add("@Plant", SqlDbType.VarChar, 20, "Plant");
                command.Parameters.Add("@Carrier", SqlDbType.VarChar, 30, "Carrier");
                command.Parameters.Add("@Delivery", SqlDbType.VarChar, 30, "Delivery");
                command.Parameters.Add("@ItemNum", SqlDbType.VarChar, 20, "ItemNum");
                command.Parameters.Add("@SSCC", SqlDbType.VarChar, 30, "SSCC");
                command.Parameters.Add("@CartonBoxNum", SqlDbType.VarChar, 40, "CartonBoxNum");