Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. First time to use oledbconnection, but I failed. :(

First time to use oledbconnection, but I failed. :(

Scheduled Pinned Locked Moved C#
csharpdatabasecomhelpquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Feng Qin
    wrote on last edited by
    #1

    1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?

    Richard DeemingR L R 3 Replies Last reply
    0
    • F Feng Qin

      1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You have three options:

      1. If you're connecting to SQL Server, you could use the SQLConnection and related objects in the System.Data.SqlClient namespace;
      2. If you really need an OLEDB connection, use the OLE DB Provider for SQL Server (SQLOLEDB.1), or the equivalent for your data source;
      3. If you absolutely must have an ODBC connection, you need to download the ODBC provider for .Net and use that instead;

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      F 1 Reply Last reply
      0
      • F Feng Qin

        1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        if u just wanna use access like me, just use a JET OLE DB connection. eg:

        string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
        accessConn = new OleDbConnection(jetConn);

        hope it helps

        1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          You have three options:

          1. If you're connecting to SQL Server, you could use the SQLConnection and related objects in the System.Data.SqlClient namespace;
          2. If you really need an OLEDB connection, use the OLE DB Provider for SQL Server (SQLOLEDB.1), or the equivalent for your data source;
          3. If you absolutely must have an ODBC connection, you need to download the ODBC provider for .Net and use that instead;
          F Offline
          F Offline
          Feng Qin
          wrote on last edited by
          #4

          Thank you. But I think the oleDbConnection should work properly when I do the steps as above, why does it reports error? I'm amumu, and you?

          Richard DeemingR 1 Reply Last reply
          0
          • F Feng Qin

            1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?

            R Offline
            R Offline
            Rene D
            wrote on last edited by
            #5

            is MDAC 2.7 installed??

            F 1 Reply Last reply
            0
            • R Rene D

              is MDAC 2.7 installed??

              F Offline
              F Offline
              Feng Qin
              wrote on last edited by
              #6

              Where can see the information?:confused: I'm amumu, and you?

              L 1 Reply Last reply
              0
              • F Feng Qin

                Thank you. But I think the oleDbConnection should work properly when I do the steps as above, why does it reports error? I'm amumu, and you?

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #7

                The objects in System.Data.OleDb do not support ODBC connections, so you can't use the OLE DB Provider for ODBC. You have to use the ODBC .Net Provider to access an ODBC data source.

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                1 Reply Last reply
                0
                • F Feng Qin

                  Where can see the information?:confused: I'm amumu, and you?

                  L Offline
                  L Offline
                  leppie
                  wrote on last edited by
                  #8

                  Either read the data in a OleDbDataReader or a OleDbDataAdapter. EG

                  //Common code
                  string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
                  accessConn = new OleDbConnection(jetConn);
                  string query = "SELECT * FROM TABLE WHERE etc etc";

                  //Reader

                  OleDbCommand myCommand = new OleDbCommand(query, accessConn);
                  OleDbDataReader myReader = myCommand.ExecuteReader();
                  while(myReader.Read())
                  {
                  string datain = myReader.GetString(0); // gets string from column 0
                  }

                  //OR DataAdapter

                  DataTable dt = new DataTable(); //can use DataSet as well
                  OleDbDataAdapter sda = new OleDbDataAdapter(query, accessConn);
                  sda.Fill(dt);

                  Hope this helps :-D

                  F 1 Reply Last reply
                  0
                  • L leppie

                    Either read the data in a OleDbDataReader or a OleDbDataAdapter. EG

                    //Common code
                    string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
                    accessConn = new OleDbConnection(jetConn);
                    string query = "SELECT * FROM TABLE WHERE etc etc";

                    //Reader

                    OleDbCommand myCommand = new OleDbCommand(query, accessConn);
                    OleDbDataReader myReader = myCommand.ExecuteReader();
                    while(myReader.Read())
                    {
                    string datain = myReader.GetString(0); // gets string from column 0
                    }

                    //OR DataAdapter

                    DataTable dt = new DataTable(); //can use DataSet as well
                    OleDbDataAdapter sda = new OleDbDataAdapter(query, accessConn);
                    sda.Fill(dt);

                    Hope this helps :-D

                    F Offline
                    F Offline
                    Feng Qin
                    wrote on last edited by
                    #9

                    Thank you:) This method can work properly. I'm amumu, and you?

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups