private void button1_Click ( object sender ,EventArgs e )
{
try
{
System.Data.Odbc.OdbcConnection ocConn = new System.Data.Odbc.OdbcConnection( );
string strTableName = @"DD0712.DBF";
string strConn =
@"Driver={Microsoft dBASE Driver (*.dbf)};SourceType=DBF;" +
@"Data Source=" + strTableName + ";Exclusive=No;NULL=NO;" +
@"Collate=Machine;BACKGROUNDFETCH=NO;DELETE=NO";
ocConn.ConnectionString = strConn;
ocConn.Open( );
string strSql = "SELECT * FROM DD0712.DBF";
OdbcDataAdapter oda = new OdbcDataAdapter( strSql ,ocConn );
DataTable dt = new DataTable( );
oda.Fill( dt );
dataGridView1.DataSource = dt;
ocConn.Close( );
}
catch ( Exception ex )
{
MessageBox.Show( ex.Message );
}
}
用c#打开.DBF文件 读取内容到DataTable或DataSet中
最新推荐文章于 2022-10-20 16:33:29 发布