On 23 Feb 2004 06:33:01 -0800,
(E-Mail Removed) (TF) wrote:
¤ Hi,
¤ I have to access data from a comma delimited file in .net windows
¤ application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0
¤ provider for this purpose. Now the problem is when i extract data from
¤ a file with extension csv or txt it works fine but as soon as i change
¤ the extension, like 'log' or 'abc' it gives following error in 'Fill'
¤ function of 'OleDbDataAdapter':
¤
¤ Cannot update. Database or object is read-only
¤
¤ I've added file entry in 'schema.ini' file, also I've created a dummy
¤ System DSN and added new extension 'log' in it, but no success.
¤
¤ Here is the code:
¤
¤ //--------------------------------------------
¤ string strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
¤ Source=C:\\data\\; Extended Properties=\"Text;HDR=YES;\"";
¤
¤ // open connection
¤ OleDbConnection oCon = new OleDbConnection(strConString);
¤ oCon.Open();
¤
¤ // fill data set
¤ string strSql = "SELECT * FROM datafile.txt";
¤ OleDbDataAdapter oDA = new OleDbDataAdapter( strSql, oCon );
¤ DataSet oData = new DataSet();
¤ oDA.Fill( oData, datafile.txt ); // -- error if file extension is
¤ log
¤
¤ oCon.Close();
¤ //---------------------------------------------
By default the Text ISAM driver is only set up to support specific file extensions. Modifying the
Registry or renaming the file temporarily will resolve the issue. See the following MS KB article
for more info:
ACC2000: Importing or Linking a Text File Fails for a File That Does Not Have a Valid File Name
Extension
http://support.microsoft.com/default...b;en-us;304206
Paul ~~~
(E-Mail Removed)
Microsoft MVP (Visual Basic)