我是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;
以下是我尝试使用towrite到行的代码(我只显示了一列):
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
答案 0 :(得分:0)
你试过了吗?
DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->default[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];