G
How can I find a DataRow in a DataSet by it's PrimaryKey value? This
would be similar to an SQL statement such as "SELECT * FROM MyTable
WHERE MyIndex = 2"...
In the following code I've tried to do this but "dataSet-
/* C++/CLI Code Sample (doesn't work) */
cli::array<System:ata:ataColumn ^> ^colarray =
gcnew cli::array<System:ata:ataColumn ^>(1);
colarray[0] =
dataSet->Tables["GpsData"]->Columns["Distance"];
dataSet->Tables["GpsData"]->PrimaryKey =
colarray;
DataRow ^drow =
dataSet->Tables["GpsData"]->Rows->Find(
dataSet->Tables["CisData"]->Rows["GpsIndexFK"]
);
if(drow != nullptr)
System::Windows::Forms::MessageBox::Show(
safe_cast<Int32 ^>(drow["Index"])->ToString()
);
would be similar to an SQL statement such as "SELECT * FROM MyTable
WHERE MyIndex = 2"...
In the following code I've tried to do this but "dataSet-
Tables["GpsData"]->Rows->Find" returns a nullptr every time...
/* C++/CLI Code Sample (doesn't work) */
cli::array<System:ata:ataColumn ^> ^colarray =
gcnew cli::array<System:ata:ataColumn ^>(1);
colarray[0] =
dataSet->Tables["GpsData"]->Columns["Distance"];
dataSet->Tables["GpsData"]->PrimaryKey =
colarray;
DataRow ^drow =
dataSet->Tables["GpsData"]->Rows->Find(
dataSet->Tables["CisData"]->Rows["GpsIndexFK"]
);
if(drow != nullptr)
System::Windows::Forms::MessageBox::Show(
safe_cast<Int32 ^>(drow["Index"])->ToString()
);