System.Data.OleDb.OleDBConnection OleDbCNN;
System.Data.OleDb.OleDbCommand OleDbCMD;
System.Data.OleDb.OleDbDataReader OleDbRAD;
DataTable Tab;
string cs;
cs = "Provider=vfpoledb.1;Data Source=d:\\cphoto\\数据;"
OleDbCNN = new System.Data.OleDb.OleDBConnection(cs);
cs = "select * from VfpDbf order by zkzh";
OleDbCMD = new System.Data.OleDb.OleDbCommand(cs, OleDbCNN);
OleDbRAD = OleDbCMD.ExecuteReader();
//查看表结构
Tab = new DataTable();
Tab = OleDbRAD.GetSchemaTable();
dataGridView1.DataSource = Tab;
//查看表的全部记录
Tab = new DataTable();
for (int i = 0; i < OleDbRAD.FieldCount; i++)
Tab.Columns.Add(OleDbRAD.GetName(i), OleDbRAD.GetFieldType(i));
DataRow row;
while (OleDbRAD.Read())
{
row = Tab.NewRow();
for (int i = 0; i < tab.Columns.Count; i++)
row[i] = OleDbRAD.GetValue(i);
Tab.Rows.Add(row);
}
dataGridView2.DataSource = Tab;
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1600686