在Visual Studio 2010 C++中将行写入数据集时出现问题

problems with writing rows to a DataSet in Visual Studio 2010 C++

本文关键字:数据集 问题 Studio Visual 2010 C++      更新时间:2023-10-16

我是Visual Studio 2010的新手,在MSDN上看到的C++示例很少,因此非常感谢您的帮助。

我使用ToolBox窗口中的DataSet函数创建了一个包含三列的表(为了简洁起见,我在下面的示例中省略了其中两列

我得到以下错误:

错误C3293:"Item":使用"default"访问类"System::Data::DataRow"的默认属性(索引器)

以下是VS2010实例化表生成的代码:

this->GraphInput->DataSetName = L"GraphDataIn";
this->GraphInput->Tables->AddRange(gcnew cli::array< System::Data::DataTable^ >(1) {this->RefElectInput});
//RefElectInput
this->RefElectInput->Columns->AddRange(gcnew cli::array< System::Data::DataColumn^ >(3) {this->RefElect0Av, this->RefElect0Max, this->RefElect0Min});
this->RefElectInput->MinimumCapacity = 7;
this->RefElectInput->TableName = L"RefElecInput";
//
// RefElect0Av
//
this->RefElect0Av->ColumnName = L"RefElect0Av";
this->RefElect0Av->DataType = System::Double::typeid;

以下是我尝试拖到行的代码(我只显示了一列):

DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->Item[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];
//the error data is of type doubleoccurs here.
//other column's removed.
RefElectInput->Rows->Add(myRow);

我将感谢你的帮助。

感谢Simon

您尝试过吗:

DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->default[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];