reading text files

B

Bill H

I've read text files before using the ODBC text driver, but the extensions
on the files have always been csv or txt. Now I am trying it on a file with
a .log extension and I'm getting a read-only error. If I rename the
extension to *.txt it works fine. I've added the .log to the extensions
list in the connection string.

I'm using the ODBC provider in Ado.Net.

This is my code:

string s = @"Driver={Microsoft Text Driver (*.txt;
*.csv)};Dbq=c:\temp\tmp;";
OdbcConnection cn = new OdbcConnection(s);
cn.Open();
s = "SELECT * FROM iis.log";
OdbcDataAdapter da = new OdbcDataAdapter(s, cn);
DataTable dt = new DataTable();
da.Fill(dt); //Errors on this line

ERROR [42000] [Microsoft][ODBC Text Driver] Cannot update. Database or
object is read-only.


Does anyone know the answer to this ?

Thanks
Bill
 
J

Jerry H.

I had this issue before as well, and I had to resolve it by digging
into the Registry:

For Jet 4.0:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\Text

Look for an entry marked "Import Filter" and add "*.log" to the list of
extenstions that the Jet Engine will treat as a text file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top