悬赏园豆:15
[已关闭问题]
<P> 导入dbf文件的时候只要文件名过长就报错(Microsoft jet数据库引擎找不到对象。。。),不过换了一个名称就可以导入了。我的代码如下</P>
<P> string tableName = "[" + Path.GetFileName(fileName) + "]";<BR> string directoryName = Path.GetDirectoryName(fileName);<BR> string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directoryName + ";Extended Properties=dBASE 5.0;Persist Security Info=False";<BR> DataSet dsImport = new DataSet();<BR> OleDbDataAdapter adapter = new OleDbDataAdapter();<BR> OleDbCommand command = new OleDbCommand();<BR> command.Connection = new OleDbConnection(strConn);<BR> command.CommandText = string.Format(@"SELECT * FROM {0}", tableName);<BR> adapter.SelectCommand = command;<BR> adapter.Fill(dsImport, "tb_trans");</P>