3

I'm getting the error "Could not find installable ISAM" when I try to read csv file using OLEDB connection string.

Please assist

My code is:

       if (File .Exists(openFileDialog1 .FileName ))
       {
        ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data          Source="+openFileDialog1.FileName +";Extended Properties=text;HDR=Yes;FMT=Delimited");
        Con = new OleDbConnection(ConnectionString);
        string query = "Select * From [Sheet1$]";
        Con.Open();
        DataAdapter = new OleDbDataAdapter(query, Con);
        dt = new DataTable(); 
        DataAdapter.Fill(dt);

        dataGridView1.DataSource = dt;
       }
Pholoso Mams
  • 467
  • 1
  • 5
  • 19

2 Answers2

6

"This error will also be generated when the syntax of the connection string is incorrect." - msdn

When i tried to copy your connectionstring, it seemed liked there were alot of spaces in there.

 ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+openFileDialog1.FileName +";Extended Properties=text;HDR=Yes;FMT=Delimited");

if this does not seem to resolve your issue, i suggest you take a look at this

Pim
  • 177
  • 1
  • 8
  • thanks for your feetback guys. I changed my connection string to "string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=No;IMEX=1\";", FileName)" and it worked. But I need to know one thing: My table name has to be the tab name-so if I dont know the tab name that the user will have how do I put my select statement? thanks in advance – Pholoso Mams Aug 12 '13 at 10:53
3

You probably are running in 64bit. Oledb.4.0 only works in 32bit applications

Moose
  • 141
  • 3