使用OleDbConnection读取DBF文件 [英] Read DBF file with OleDbConnection
本文介绍了使用OleDbConnection读取DBF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我正在使用读取Shapefile(ESRI ShapeFile"* .Shp")的系统,但是我在使用数据文件".Dbf"时遇到问题,在某些情况下,我可以打开它而不会出现问题.但是在其他情况下,我无法读取记录.
这是读取文件的代码:
Hi!
I''m working on a system that reads Shapefiles (ESRI ShapeFile "*.Shp"), and I''m having problems with the data file ".Dbf", in some cases i can open it without problems. But in other cases i can''t read the records.
Here is the code to read the File:
OleDbConnection connection = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName( fileName ) + ";Extended Properties=DBASE III" );
connection.Open( );
OleDbDataAdapter adapter = new OleDbDataAdapter( "select * from " + Path.GetFileName( fileName ), connection );
DataSet dataSet = new DataSet( ); ;
adapter.Fill( dataSet );
if ( dataSet.Tables.Count > 0 ) {
data = dataSet.Tables[ 0 ];
}
这是错误消息:
System.Data.OleDb.OleDbException:由外部数据库的驱动程序引起的意外错误(8961).
有人可以帮我吗?
And Here is the Error Message:
System.Data.OleDb.OleDbException: nexpected error caused by drivers from external database (8961).
Can anyone help me?
推荐答案
这可以帮助您解决错误.-
http://support.microsoft.com/kb/321003 [
this may help you about error.-
http://support.microsoft.com/kb/321003[^]
这篇关于使用OleDbConnection读取DBF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文