📄 dataset1.h
字号:
tableMapping->ColumnMappings->Add(L"UnitPrice", L"UnitPrice");
tableMapping->ColumnMappings->Add(L"Quantity", L"Quantity");
tableMapping->ColumnMappings->Add(L"Discount", L"Discount");
this->_adapter->TableMappings->Add(tableMapping);
this->_adapter->DeleteCommand = (gcnew System::Data::Odbc::OdbcCommand());
this->_adapter->DeleteCommand->Connection = this->Connection;
this->_adapter->DeleteCommand->CommandText = L"DELETE FROM [Order Details] WHERE (([OrderID] = \?) AND ([ProductID] = \?) AND ((\? "
L"= 1 AND [UnitPrice] IS NULL) OR ([UnitPrice] = \?)) AND ((\? = 1 AND [Quantity] IS"
L" NULL) OR ([Quantity] = \?)) AND ((\? = 1 AND [Discount] IS NULL) OR ([Discount] ="
L" \?)))";
this->_adapter->DeleteCommand->CommandType = System::Data::CommandType::Text;
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_OrderID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"OrderID", System::Data::DataRowVersion::Original,
false, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_ProductID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"ProductID",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"IsNull_UnitPrice", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"UnitPrice",
System::Data::DataRowVersion::Original, true, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_UnitPrice", System::Data::Odbc::OdbcType::Numeric,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(19), static_cast<System::Byte>(4), L"UnitPrice",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"IsNull_Quantity", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Quantity",
System::Data::DataRowVersion::Original, true, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_Quantity", System::Data::Odbc::OdbcType::SmallInt,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Quantity",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"IsNull_Discount", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Discount",
System::Data::DataRowVersion::Original, true, nullptr)));
this->_adapter->DeleteCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_Discount", System::Data::Odbc::OdbcType::Real,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Discount",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->InsertCommand = (gcnew System::Data::Odbc::OdbcCommand());
this->_adapter->InsertCommand->Connection = this->Connection;
this->_adapter->InsertCommand->CommandText = L"INSERT INTO [Order Details] ([OrderID], [ProductID], [UnitPrice], [Quantity], [Di"
L"scount]) VALUES (\?, \?, \?, \?, \?)";
this->_adapter->InsertCommand->CommandType = System::Data::CommandType::Text;
this->_adapter->InsertCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"OrderID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"OrderID", System::Data::DataRowVersion::Current,
false, nullptr)));
this->_adapter->InsertCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"ProductID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"ProductID",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->InsertCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"UnitPrice", System::Data::Odbc::OdbcType::Numeric,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(19), static_cast<System::Byte>(4), L"UnitPrice",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->InsertCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Quantity", System::Data::Odbc::OdbcType::SmallInt,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Quantity",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->InsertCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Discount", System::Data::Odbc::OdbcType::Real,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Discount",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->UpdateCommand = (gcnew System::Data::Odbc::OdbcCommand());
this->_adapter->UpdateCommand->Connection = this->Connection;
this->_adapter->UpdateCommand->CommandText = L"UPDATE [Order Details] SET [OrderID] = \?, [ProductID] = \?, [UnitPrice] = \?, [Quan"
L"tity] = \?, [Discount] = \? WHERE (([OrderID] = \?) AND ([ProductID] = \?) AND ((\? ="
L" 1 AND [UnitPrice] IS NULL) OR ([UnitPrice] = \?)) AND ((\? = 1 AND [Quantity] IS "
L"NULL) OR ([Quantity] = \?)) AND ((\? = 1 AND [Discount] IS NULL) OR ([Discount] = "
L"\?)))";
this->_adapter->UpdateCommand->CommandType = System::Data::CommandType::Text;
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"OrderID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"OrderID", System::Data::DataRowVersion::Current,
false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"ProductID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"ProductID",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"UnitPrice", System::Data::Odbc::OdbcType::Numeric,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(19), static_cast<System::Byte>(4), L"UnitPrice",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Quantity", System::Data::Odbc::OdbcType::SmallInt,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Quantity",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Discount", System::Data::Odbc::OdbcType::Real,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Discount",
System::Data::DataRowVersion::Current, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_OrderID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"OrderID", System::Data::DataRowVersion::Original,
false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_ProductID", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"ProductID",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"IsNull_UnitPrice", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"UnitPrice",
System::Data::DataRowVersion::Original, true, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_UnitPrice", System::Data::Odbc::OdbcType::Numeric,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(19), static_cast<System::Byte>(4), L"UnitPrice",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"IsNull_Quantity", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Quantity",
System::Data::DataRowVersion::Original, true, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_Quantity", System::Data::Odbc::OdbcType::SmallInt,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Quantity",
System::Data::DataRowVersion::Original, false, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"IsNull_Discount", System::Data::Odbc::OdbcType::Int,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Discount",
System::Data::DataRowVersion::Original, true, nullptr)));
this->_adapter->UpdateCommand->Parameters->Add((gcnew System::Data::Odbc::OdbcParameter(L"Original_Discount", System::Data::Odbc::OdbcType::Real,
0, System::Data::ParameterDirection::Input, static_cast<System::Byte>(0), static_cast<System::Byte>(0), L"Discount",
System::Data::DataRowVersion::Original, false, nullptr)));
}
inline System::Void Order_DetailsTableAdapter::InitConnection() {
this->_connection = (gcnew System::Data::Odbc::OdbcConnection());
this->_connection->ConnectionString = L"Dsn=Northwind;dbq=D:\\Beginning Visual C++ 2005\\Model Access DB\\Northwind.mdb;driv"
L"erid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5";
}
inline System::Void Order_DetailsTableAdapter::InitCommandCollection() {
this->_commandCollection = gcnew cli::array< System::Data::Odbc::OdbcCommand^ >(1);
this->_commandCollection[0] = (gcnew System::Data::Odbc::OdbcCommand());
this->_commandCollection[0]->Connection = this->Connection;
this->_commandCollection[0]->CommandText = L"SELECT OrderID, ProductID, UnitPrice, Quantity, Discount FROM [Order Details]";
this->_commandCollection[0]->CommandType = System::Data::CommandType::Text;
}
inline System::Int32 Order_DetailsTableAdapter::Fill(Ex22_04::DataSet1::Order_DetailsDataTable^ dataTable) {
this->Adapter->SelectCommand = this->CommandCollection[0];
if (this->ClearBeforeFill == true) {
dataTable->Clear();
}
System::Int32 returnValue = this->Adapter->Fill(dataTable);
return returnValue;
}
inline Ex22_04::DataSet1::Order_DetailsDataTable^ Order_DetailsTableAdapter::GetData() {
this->Adapter->SelectCommand = this->CommandCollection[0];
Ex22_04::DataSet1::Order_DetailsDataTable^ dataTable = (gcnew Ex22_04::DataSet1::Order_DetailsDataTable());
this->Adapter->Fill(dataTable);
return dataTable;
}
inline System::Int32 Order_DetailsTableAdapter::Update(Ex22_04::DataSet1::Order_DetailsDataTable^ dataTable) {
return this->Adapter->Update(dataTable);
}
inline System::Int32 Order_DetailsTableAdapter::Update(Ex22_04::DataSet1^ dataSet) {
return this->Adapter->Update(dataSet, L"Order Details");
}
inline System::Int32 Order_DetailsTableAdapter::Update(System::Data::DataRow^ dataRow) {
return this->Adapter->Update(gcnew cli::array< System::Data::DataRow^ >(1) {dataRow});
}
inline System::Int32 Order_DetailsTableAdapter::Update(cli::array< System::Data::DataRow^ >^ dataRows) {
return this->Adapter->Update(dataRows);
}
inline System::Int32 Order_DetailsTableAdapter::Delete(System::Nullable<System::Int32 > Original_OrderID, System::Nullable<System::Int32 > Original_ProductID,
System::Nullable<System::Decimal > Original_UnitPrice, System::Nullable<System::Int16 > Original_Quantity, System::Nullable<System::Single > Original_Discount) {
if (Original_OrderID.HasValue == true) {
this->Adapter->DeleteCommand->Parameters[0]->Value = static_cast<System::Int32>(Original_OrderID.Value);
}
else {
this->Adapter->DeleteCommand->Parameters[0]->Value = System::DBNull::Value;
}
if (Original_ProductID.HasValue == true) {
this->Adapter->DeleteCommand->Parameters[1]->Value = static_cast<System::Int32>(Original_ProductID.Value);
}
else {
this->Adapter->DeleteCommand->Parameters[1]->Value = System::DBNull::Value;
}
if (Original_UnitPrice.HasValue == true) {
this->Adapter->DeleteCommand->Parameters[2]->Value = cli::safe_cast<System::Object^>(0);
this->Adapter->DeleteCommand->Parameters[3]->Value = static_cast<System::Decimal>(Original_UnitPrice.Value);
}
else {
this->Adapter->DeleteCommand->Parameters[2]->Value = cli::safe_cast<System::Object^>(1);
this->Adapter->DeleteCommand->Parameters[3]->Value = System::DBNull::Value;
}
if (Original_Quantity.HasValue == true) {
this->Adapter->DeleteCommand->Parameters[4]->Value = cli::safe_cast<System::Object^>(0);
this->Adapter->DeleteCommand->Parameters[5]->Value = static_cast<System::Int16>(Original_Quantity.Value);
}
else {
this->Adapter->DeleteCommand->Parameters[4]->Value = cli::safe_cast<System::Object^>(1);
this->Adapter->DeleteCommand->Parameters[5]->Value = System::DBNull::Value;
}
if (Original_Discount.HasValue == true) {
this->Adapter->DeleteCommand->Parameters[6]->Value = cli::safe_cast<System::Object^>(0);
this->Adapter->DeleteCommand->Parameters[7]->Value = static_cast<System::Single>(Original_Discount.Value);
}
else {
this->Adapter->DeleteCommand->Parameters[6]->Value = cli::safe_cast<System::Object^>(1);
this->Adapter->DeleteCommand->Parameters[7]->Value = System::DBNull::Value;
}
System::Data::ConnectionState previousConnectionState = this->Adapter->DeleteCommand->Connection->State;
if ((this->Adapter->DeleteCommand->Connection->State & System::Data::ConnectionState::Open)
!= System::Data::ConnectionState::Open) {
this->Adapter->DeleteCommand->Connection->Open();
}
try {
System::Int32 returnValue = this->Adapter->DeleteCommand->ExecuteNonQuery();
return returnValue;
}
finally {
if (previousConnectionState == System::Data::ConnectionState::Closed) {
this->Adapter->DeleteCommand->Connection->Close();
}
}
}
inline System::Int32 Order_DetailsTableAdapter::Insert(System::Nullable<System::Int32 > OrderID, System::Nullable<System::Int32 > ProductID,
System::Nullable<System::Decimal > UnitPrice, System::Nullable<System::Int16 > Quantity, System::Nullable<System::Single > Discount) {
if (OrderID.HasValue == true) {
this->Adapter->InsertCommand->Parameters[0]->Value = static_cast<System::Int32>(OrderID.Value);
}
else {
this->Adapter->InsertCommand->Parameters[0]->Value = System::DBNull::Value;
}
if (ProductID.HasValue == true) {
this->Adapter->InsertCommand->Parameters[1]->Value = static_cast<System::Int32>(ProductID.Value);
}
else {
this->Adapter->InsertCommand->Parameters[1]->Value = System::DBNull::Value;
}
if (UnitPrice.HasValue == true) {
this->Adapter->InsertCommand->Parameters[2]->Value = static_cast<System::Decimal>(UnitPrice.Value);
}
else {
this->Adapter->InsertCommand->Parameters[2]->Value = System::DBNull::Value;
}
if (Quantity.HasValue == true) {
this->Adapter->InsertCommand->Parameters[3]->Value = static_cast<System::Int16>(Quantity.Value);
}
else {
this->Adapter->InsertCommand->Parameters[3]->Value = System::DBNull::Value;
}
if (Discount.HasValue == true) {
this->Adapter
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -