Sunday, February 17, 2013

Visual C++ Windows Form Application Mysql Connection


1.Create a new C++ Windows Form Application.

2.Go to Project > Project Name Properties > Add New Reference > Select the Tab .NET

3. Scroll down till you see MySQL.Data then Double Click it or Click it and Press OK then Press OK again (If you don't see it then you cant have the MySQL Connector Installed).


4. Double Click on the Form then Scroll the code till you see using namespace System::Drawing;

5. Below that type using namespace MySql::Data::MySqlClient;

6.Go back to the Form Design and Add a Button to do the connection.So when we click the button , the button will establish the connection to MySQL.

Button means your item!

7.Double click on the Button to go to code section and add the following Code:

Fill in the Port, Username, Password and Hostname with your MySQL Information.

String^ constring = L"datasource=localhost;port=3306;username=root;password=root"; 
MySqlConnection^ conDataBase = gcnew MySqlConnection( constring ); 
MySqlCommand ^cmdDataBase = gcnew MySqlCommand("select * from `database`.`edata` where password='" + this->password->Text +"' ;", conDataBase ); 
MySqlDataReader ^myReader; 
try{
conDataBase->Open(); 
myReader = cmdDataBase->ExecuteReader(); 
int count=0;
while (myReader->Read()) {
      // username->Text  +=(myReader->GetInt32(0) + ", " + myReader->GetString(1)+", "+myReader->GetString(2) + ", " + myReader->GetInt32(3)+ "\r\n");
    
}

}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}


8.Now run the program and see the response in the message box .




Visual C++ Tutorial 2 -Windows Forms Application: 

Mysql Connection Part 1 




Visual C++ Tutorial 3 -Windows Forms Application: Mysql Connection Part 2 




C++ Windows Form Application Mysql Connection
Using Visual C++ Windows Forms with MySQL
C++ Windows Form Application Mysql Connection
Mysql And Visual C++ 2010 Windows Form Application
MySQL :: Connecting to MySQL with a WindowsForm application
C++ Form textbox string into SQL Database
visual c++ CLR windows form application and mysql
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ