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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Connect to MySQL from MFC Dlg

Connect to MySQL from MFC Dlg

Scheduled Pinned Locked Moved C / C++ / MFC
c++cssdatabasemysql
7 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.
  • Q Offline
    Q Offline
    QuickDeveloper
    wrote on last edited by
    #1

    hi I want to connect to MySQL database when i click a button in MFC dialog based application. 1)I searched web (including CP) but i didn't find exact info since there seems to be various methods to connect including DSN less (using MySQL++) 2)I have downloaded MySQL database & ODBC connector but i am not able to connect to it even while creating DSN(From Control Panel). 3)I am able to create tables etc on MySQL command line but not able to establish link between database & VC++ App. Can anyone point me to a simple article which explains connecting to MySQl and inserting a record into it(with DSN or without DSN) thanx in advance

    "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

    K H D 3 Replies Last reply
    0
    • Q QuickDeveloper

      hi I want to connect to MySQL database when i click a button in MFC dialog based application. 1)I searched web (including CP) but i didn't find exact info since there seems to be various methods to connect including DSN less (using MySQL++) 2)I have downloaded MySQL database & ODBC connector but i am not able to connect to it even while creating DSN(From Control Panel). 3)I am able to create tables etc on MySQL command line but not able to establish link between database & VC++ App. Can anyone point me to a simple article which explains connecting to MySQl and inserting a record into it(with DSN or without DSN) thanx in advance

      "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

      K Offline
      K Offline
      Kiran Pinjala
      wrote on last edited by
      #2

      MySql installation will provide you with soem documentation for api's to be used for all operations with MySql Database. Some of them are

      void *mydata;
      //initialize and connect to mysql database
      mysql_init((MYSQL*) 0);
      mysql_real_connect((MYSQL*) myData,dbHost,dbUID,dbPWD, NULL, MYSQL_PORT, NULL,0);
      //select the database to futher operations
      mysql_select_db( (MYSQL*)myData,"MYSQL");
      // run aquery
      mysql_query((MYSQL*)myData, "select * from mysql.host");

      Saadhinchaali

      K 1 Reply Last reply
      0
      • K Kiran Pinjala

        MySql installation will provide you with soem documentation for api's to be used for all operations with MySql Database. Some of them are

        void *mydata;
        //initialize and connect to mysql database
        mysql_init((MYSQL*) 0);
        mysql_real_connect((MYSQL*) myData,dbHost,dbUID,dbPWD, NULL, MYSQL_PORT, NULL,0);
        //select the database to futher operations
        mysql_select_db( (MYSQL*)myData,"MYSQL");
        // run aquery
        mysql_query((MYSQL*)myData, "select * from mysql.host");

        Saadhinchaali

        K Offline
        K Offline
        Kiran Pinjala
        wrote on last edited by
        #3

        See here

        Saadhinchaali

        1 Reply Last reply
        0
        • Q QuickDeveloper

          hi I want to connect to MySQL database when i click a button in MFC dialog based application. 1)I searched web (including CP) but i didn't find exact info since there seems to be various methods to connect including DSN less (using MySQL++) 2)I have downloaded MySQL database & ODBC connector but i am not able to connect to it even while creating DSN(From Control Panel). 3)I am able to create tables etc on MySQL command line but not able to establish link between database & VC++ App. Can anyone point me to a simple article which explains connecting to MySQl and inserting a record into it(with DSN or without DSN) thanx in advance

          "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          See Using Visual C++ 6.0 to connect to MySQL[^]. <blockquote class="FQ"><div class="FQA">QuickDeveloper wrote:</div>"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"</blockquote> if you find your name in that list do you go to work if see your name in the middle of list? ;)

          1 Reply Last reply
          0
          • Q QuickDeveloper

            hi I want to connect to MySQL database when i click a button in MFC dialog based application. 1)I searched web (including CP) but i didn't find exact info since there seems to be various methods to connect including DSN less (using MySQL++) 2)I have downloaded MySQL database & ODBC connector but i am not able to connect to it even while creating DSN(From Control Panel). 3)I am able to create tables etc on MySQL command line but not able to establish link between database & VC++ App. Can anyone point me to a simple article which explains connecting to MySQl and inserting a record into it(with DSN or without DSN) thanx in advance

            "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            QuickDeveloper wrote:

            I want to connect to MySQL database when i click a button in MFC dialog based application.

            So what are you having trouble with: 1) connecting to the data source, or 2) responding to a button click?

            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            Q 1 Reply Last reply
            0
            • D David Crow

              QuickDeveloper wrote:

              I want to connect to MySQL database when i click a button in MFC dialog based application.

              So what are you having trouble with: 1) connecting to the data source, or 2) responding to a button click?

              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              Q Offline
              Q Offline
              QuickDeveloper
              wrote on last edited by
              #6

              DavidCrow wrote:

              1. connecting to the data source,

              Connecting to the datasource while creating DSN

              "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

              D 1 Reply Last reply
              0
              • Q QuickDeveloper

                DavidCrow wrote:

                1. connecting to the data source,

                Connecting to the datasource while creating DSN

                "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                One way is to create a CRecordset-derived object. ClassWizard (Ctrl+W) will ask you what DSN to use.

                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                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