I'm trying to read the DBase file in WebForm.
I have succeed in doing that only if that file has *.dbf extension and the filename is shorter than 8 characters with either of these 2 methods
Code:
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("DBaseFile/")+";Extended Properties=DBase IV;";
OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM test.dbf",strConn);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet);
DataGrid1.DataSource = myDataSet.Tables[0].DefaultView;
DataGrid1.DataBind();
or
Code:
OdbcConnection conn = new OdbcConnection();
conn.ConnectionString = "Driver={Microsoft dBASE Driver (*.dbf)};" +
"DriverID=277;" +
"Dbq="+Server.MapPath("DBaseFile/");
OdbcDataAdapter adapter = new OdbcDataAdapter();
adapter.SelectCommand = new OdbcCommand("Select * FROM [test.dbf]", conn);
adapter.Fill(myDataSet);
DataGrid1.DataSource = myDataSet.Tables[0].DefaultView;
DataGrid1.DataBind();
but the above code do not work when the file name of the dbase file is longer than 8 characters or if the extension of dbase file is something else ( any arbitary extension, eg: test.abc)
is there anyway to get around this without first rename my dbase file to the correct format?
because my program will process lots of 3rd party dbase files so it will slow down the process a lot if i need to rename all those files.
Thank You