首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

三表更新,未将对象引用设置到对象实例错误

2014-01-28 
三表更新使用事务未将对象引用设置到对象实例 { this-StorageAdapter new SqlDataAdapter() this-Stor

三表更新使用事务未将对象引用设置到对象实例
{
this->StorageAdapter = new SqlDataAdapter();
this->StorageAdapter->add_RowUpdating(new SqlRowUpdatingEventHandler(0,this->UpdateStorage));
this->StorageAdapter->UpdateCommand = new SqlCommand();
this->StorageAdapter->UpdateCommand->CommandText = S"Update 库存库 Set 库存数量 = @库存数量 Where 货号 = @货号 AND  仓库 = @仓库";
this->StorageAdapter->UpdateCommand->Connection = this->MyDataBase->myConnection;
this->StorageAdapter->UpdateCommand->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@货号", System::Data::SqlDbType::VarChar, 14, S"货号"));……
this->StorageAdapter->InsertCommand = new SqlCommand();
this->StorageAdapter->InsertCommand->CommandText = S"Insert Into 库存库 (货号,仓库,库存数量,库存金额,库存单价) Values (@货号,@仓库,@库存数量,@库存金额,@库存单价)";
……;
this->ImportDetailAdapter = new SqlDataAdapter();
this->ImportDetailAdapter->add_RowUpdating(new SqlRowUpdatingEventHandler(0,this->UpdateImportDetail));
//Update
this->ImportDetailAdapter->UpdateCommand = new SqlCommand();
this->ImportDetailAdapter->UpdateCommand->CommandText = S"UPDATE 进货单明细 SET 编号 = @编号, 进货单号 = @进货单号, 货号 = @货号, 进货数量 = @进货数量, 进价 = @进价,扣率 = @扣率, 税率 = @税率, 仓库 = @仓库, 货物质量 = @货物质量 WHERE (编号 = @Original_编号)";
this->ImportDetailAdapter->UpdateCommand->Connection = this->MyDataBase->myConnection;
this->ImportDetailAdapter->UpdateCommand->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@编号", System::Data::SqlDbType::VarChar, 14, S"编号"));
……
//Insert
this->ImportDetailAdapter->InsertCommand = new SqlCommand();
this->ImportDetailAdapter->InsertCommand->CommandText = S"INSERT INTO 进货单明细(编号, 进货单号, 货号, 进货数量, 进价, 扣率, 税率, 仓库,货物质量) VALUES (@编号, @进货单号, @货号, @进货数量, @进价, @税价合计, @扣率, @税率, @不含税价, @税额, @仓库, @货物质量)";
……//Delete
this->ImportDetailAdapter->DeleteCommand = new SqlCommand();
this->ImportDetailAdapter->DeleteCommand->CommandText = S"DELETE FROM 进货单明细 WHERE (编号 = @Original_编号)";
this->ImportDetailAdapter->DeleteCommand->Connection = this->MyDataBase->myConnection;
this->ImportDetailAdapter->DeleteCommand->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@Original_编号", System::Data::SqlDbType::VarChar, 14, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"编号", System::Data::DataRowVersion::Original, 0));
this->ImportTableAdapter = new SqlDataAdapter();
this->dgrdImportTable->Enabled = false;         

热点排行