Microsoft Access DSNLess connection error, works fine in .ASP page, not in aspx code.

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

Trying this code in the Page_Load of a C# web page...

private void Page_Load(object sender, System.EventArgs e)
{
string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\MyAccessDb.mdb;";
OdbcConnection conn = new OdbcConnection(connstr);
conn.Open();
...

Throws this error
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found
and no default driver specified

But the same connection string works fine in a regular ol' ASP page, any
ideas?

Thanks!

Derrick
 
and let me clarify, the same connection below string works fine in asp page
when creating an ADO.Recordset object and then setting the below
connectionstring as the ActiveConnection prop.
 
The connection string is fine. It's the rest of your code that is the
problem. Try using the .Net OleDb classes instead.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top