1

文件 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
4

1 回答 1

1

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

尝试 { string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\ZIP.DBF;Extended Properties=dBase IV"; OleDbConnection conn = 新 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 );

     }      
于 2013-09-26T15:33:33.330 回答