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

Discussion in 'ASP .Net' started by Derrick, Aug 26, 2004.

  1. Derrick

    Derrick Guest

    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
     
    Derrick, Aug 26, 2004
    #1
    1. Advertising

  2. Derrick

    Derrick Guest

    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.


    "Derrick" <> wrote in message
    news:%23%23j$...
    > 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
    >
    >
    >
    >
    >
    >
    >
    >
     
    Derrick, Aug 26, 2004
    #2
    1. Advertising

  3. 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.

    "Derrick" <> wrote in message
    news:##j$...
    > 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
    >
    >
    >
    >
    >
    >
    >
    >
     
    Kevin Spencer, Aug 26, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. no-spamJim

    aspx gives dns error, html works fine

    no-spamJim, Apr 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,167
    no-spamJim
    Apr 6, 2005
  2. .spider
    Replies:
    2
    Views:
    518
    Juan T. Llibre
    Jul 17, 2007
  3. guy
    Replies:
    2
    Views:
    445
    Aaron Bertrand [MVP]
    Feb 23, 2004
  4. shank

    DSNLess troubles

    shank, Jul 17, 2004, in forum: ASP General
    Replies:
    4
    Views:
    112
    dlbjr
    Jul 17, 2004
  5. rob merritt

    perl as win32 and DSNless con to mdb?

    rob merritt, Aug 1, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    96
    mgarrish
    Aug 2, 2003
Loading...

Share This Page