我在Access中有两个表:
客户
订单
3)Id_Customer
OleDbConnection con = new OleDbConnection(strProvider);
OleDbCommand cmd = new OleDbCommand(strSql, con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
DataTable dtTree = new DataTable();
int columnCount = dr.FieldCount;
for (int i = 0; i < columnCount; i++)
{
dataGridView1.Columns.Add(dr.GetName(i).ToString(), dr.GetName(i).ToString());
}
string[] rowData = new string[columnCount];
while (dr.Read())
{
for (int k = 0; k < columnCount; k++)
{
if (dr.GetFieldType(k).ToString() == "System.Int32")
{
rowData[k] = dr.GetInt32(k).ToString();
}
if (dr.GetFieldType(k).ToString() == "System.String")
{
rowData[k] = dr.GetString(k);
}
}
dataGridView1.Rows.Add(rowData);
}
如何将这些数据添加到Treeview中?