string filename = FileUpload1.PostedFile.FileName;
//上传文件的全部路径
string type = Path.GetExtension(filename);
//获得最后一个\的索引
int n = filename.LastIndexOf( "\\ ");
filename = filename.Substring(0, n );
string filenamed = FileUpload1.FileName;
int m = filenamed.LastIndexOf( ". ");
string tablename = filenamed.Substring(0, m);
string constr;
constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ' " + filename + " ';Extended Properties=dBASE IV;User ID=Admin;Password= ";
OleDbConnection con = new OleDbConnection(constr);
con.Open();
string sql = "select * from " + tablename;
OleDbCommand com = new OleDbCommand(sql, con);
OleDbDataReader dr = com.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
dr.Close();
con.Close();
有不可以啊 说什么 :::::::::::::::::::::
外部表不是预期的格式。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 外部表不是预期的格式。
------解决方案--------------------------------------------------------
OLE DB, OleDbConnection (.NET)
Standard
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;Extended Properties=dBASE IV;User ID=Admin;Password=;
http://www.connectionstrings.com/?carrier=dbffoxpro
对比下,似乎 lZ 的没有错
OR -> VF ?
OLE DB, OleDbConnection (.NET)
Database container (.DBC)
Provider=vfpoledb.1;Data Source=C:\MyDbFolder\MyDbContainer.dbc;Collating Sequence=machine;