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

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

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

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,250
    no-spamJim
    Apr 6, 2005
  2. Eric
    Replies:
    5
    Views:
    727
  3. bazzer
    Replies:
    0
    Views:
    1,197
    bazzer
    Mar 24, 2006
  4. bazzer
    Replies:
    1
    Views:
    1,534
    sirfunusa
    Mar 24, 2006
  5. bazzer
    Replies:
    0
    Views:
    11,331
    bazzer
    Mar 30, 2006
  6. .spider
    Replies:
    2
    Views:
    647
    Juan T. Llibre
    Jul 17, 2007
  7. guy
    Replies:
    2
    Views:
    645
    Aaron Bertrand [MVP]
    Feb 23, 2004
  8. Avi
    Replies:
    1
    Views:
    291
    Martin Honnen
    Oct 24, 2005
Loading...