B. *_*non 5 c# oracle dynamic winforms dotconnect
使用此代码:
OracleDataTable dt = PlatypusSchedData.GetAvailablePlatypi();
OracleDataTable outputDt = new OracleDataTable();
int iRows = 12;
while (iRows > 0)
{
outputDt.Rows.Add(new DataRow()); // line 1
//var dr = new DataRow(); // line 2a
//outputDt.Rows.Add(dr); // line 2b
iRows -= 1;
}
for (int i = 0; i < dt.Rows.Count; i += 1) {
DataRow dr = dt.Rows[i];
int outputColumn = 0;
if (i % 12 == 0 && i > 0) {
outputColumn += 1; //2?
}
outputDt.Rows[i % 12][outputColumn] = dr[0];
outputDt.Rows[i % 12][outputColumn + 1] = dr[1];
}
dataGridView1.DataSource = outputDt;
Run Code Online (Sandbox Code Playgroud)
...我使用第1行(注释掉的第2a和2b行)或使用第2a和2b行(第1行注释掉)得到此编译时错误:
由于其保护级别,'System.Data.DataRow.DataRow(System.Data.DataRowBuilder)'无法访问
这让我感到困惑,因为for循环中的DataRow是可以容忍的.如何将这些DataRows添加到OracleDataTable中?
Ste*_*tty 19
构造函数DataRow标记为protected internal,因此,您无法直接构造它.
获取a的新行的正确代码DataTable是
DataRow dr = dt.NewRow();
Run Code Online (Sandbox Code Playgroud)