Asp.net 读取文件.dbf错误连接.打开()

本文关键字:连接 打开 错误 dbf net 读取 文件 Asp | 更新日期: 2023-09-27 18:32:59

file dbf: C:''myTable.dbf;法典:

var file = @" C:'myTable.dbf";
var connectionString = @"Provider=vfpoledb;Data Source=" + file + ";Collating Sequence=machine;";
OdbcConnection conn = new OdbcConnection(connectionString);
conn.Open();
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Asp.net 读取文件.dbf错误连接.打开()

你能尝试更改连接字符串提供程序吗

尝试 { string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:''ZIP..DBF;扩展属性=dBase IV"; OleDbConnection conn = new OleDbConnection ( conString ); 命令 = 连接。创建命令 ( );

     // create the DataSet
     DataSet ds = new DataSet ( );
     dataGridView1 . DataSource = null;
     // open the connection
     conn . Open ( );
     string commandString = "Select * from  ZIP.DBF";
     // run the query
     command . CommandText = commandString;
     OleDbDataAdapter adapter = new OleDbDataAdapter ( command );
     adapter . Fill ( ds );
     // close the connection
     conn . Close ( );
     // set the grid's data source
     dataGridView1 . DataSource = ds . Tables [ 0 ];
     }
 catch ( Exception ex)
     {
     MessageBox . Show (  ex . Message );
     }