-1
我已將Visual Studio 2013連接到Oracle XE 11數據庫。我試圖使用下面的代碼從數據庫中的表中檢索信息,但似乎數組裝飾沒有使用我在foreach循環中設置的值進行初始化。 請幫忙。Null數組異常:未從Oracle數據庫初始化
conn.Open(); // it is an OleDbConnection
String[] decor;
DataTable table1 = new DataTable();
OleDbDataAdapter oda1 = new OleDbDataAdapter("select name from Product where Commodity_Type='decor'",conn);
oda1.Fill(table1);
int j=0;
foreach (DataRow row in table1.Rows)
{
decor[j] = row["name"].ToString();
j++;
}
非常感謝!它的工作:D –