您的位置:首页 > 编程语言 > ASP

Asp.Net中用OLEDB读dbf文件,报“外部表不是预期的格式”错误的处理

2010-05-14 11:03 761 查看
Asp.Net中用OLEDB读dbf文件,报“外部表不是预期的格式”错误

我的代码如下

string tempfile = filePrefix + Year + Month + ssdm;
fileName=serverPath+@"OutPutDataFiles/"+tempfile+".dbf";
File.Copy(serverPath+@"OutPutDataFiles/"+templeFile,fileName,true);
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + serverPath + @"OutputDataFiles/" + ";Extended Properties=dBASE 5.0";
string sql="";
sql="Select  *  From  "+ tempfile;
OleDbDataAdapter  adpt=new  OleDbDataAdapter(sql,strConn);
OleDbCommandBuilder  bd  =new  OleDbCommandBuilder  (adpt);
DataSet mySet=new DataSet();
adpt.Fill(mySet, tempfile);
MoveBatch(dataSource,mySet.Tables[tempfile]);//批量导出数据

adpt.Update(mySet, tempfile);

由于dbf文件版本较高,OLEDB4.0无法打开。可先用Excel打开试一下,若打不开,就是这种情况。
所以需要先安装VFP9的OLEDB驱动vfpoledb.exe,然后修改strConn
string strConn = @"Provider=VFPOLEDB.1 ;Data Source=" + serverPath + @"OutputDataFiles/";
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐