Problem opening OleDB Excel connection

  • Thread starter Thread starter aacool
  • Start date Start date
A

aacool

Hi,

I've been trying to open an Excel connection through OLEDB with the code
below:

string ConnectString =@"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" + fileName.Text + ";ExtendedProperties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = ConnectString;
conn.Open();

This throws the Exception "Could not find installable ISAM"

I've verified that msexcl40.dll exists in c:\windows\system32 and have
even re-registered it. No luck - please help:)

TIA
aacool
 
/// <para>OleDb:Provider=Microsoft.Jet.OLEDB.4.0;Extended
Properties=""Excel 8.0;"";Data
Source="+s_DocumentFolder+s_DataSetNamespace+".xls;"</para>

Maybe a blank is missing in "ExtendedProperties" , otherwise it looks good.

Mark Johnson, Berlin Germany
(e-mail address removed)
 
Sorry the "OleDb:" part was part of documentation - it does not belong to
the string!
 
Sorry the "OleDb:" part was part of documentation - it does not belong
to the string!

I figured that - it did not work even with the space between Extended
and Properties, and without the OleDb

Thanks
aacool
 
I have written a small project with your code and have recieved the same
error.
I will work on this and report when I have found out why this happens.

Mark Johnson, Berlin Germany
(e-mail address removed)
 
The problem is with the "Extended Properties" not having a blank between the
two words.
Using your code (with the exception of a string fileName_Text instead of
fileName.Text),
the connection will not fail if "Extended Properties" is used in the
Connection string instead of "ExtendedProperties".
Please report your results of this.

Mark Johnson, Berlin Germany
(e-mail address removed)
--------------------------------
This code failed :
--------------------------------
string fileName_Text = "PRSTAT00.xls";
string ConnectString =@"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" + fileName_Text + ";ExtendedProperties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = ConnectString;
// "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=PRSTAT00.xls;ExtendedProperties=Excel 8.0;"
try
{
conn.Open();
}
catch (OleDbException e)
{
// e.Message "Installierbares ISAM nicht gefunden." string
MessageBox.Show(e.Message);
} // catch (OleDbException e)
--------------------------------
This code is OK :
--------------------------------
string fileName_Text = "PRSTAT00.xls";
string ConnectString =@"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" + fileName_Text + ";Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = ConnectString;
// "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=PRSTAT00.xls;Extended Properties=Excel 8.0;"
try
{
conn.Open();
}
catch (OleDbException e)
{
MessageBox.Show(e.Message);
} // catch (OleDbException e)
--------------------------------
 
The problem is with the "Extended Properties" not having a blank
between the two words.
Using your code (with the exception of a string fileName_Text
instead of
fileName.Text),
the connection will not fail if "Extended Properties" is used in the
Connection string instead of "ExtendedProperties".
Please report your results of this.

Mark Johnson, Berlin Germany
(e-mail address removed)

Thank you - the code worked as advised with the space

The working code is similar to the one you posted, apart from some other
stuff I need to do after opening the file, of course

aacool
 
Back
Top