Correct installation and debugging of MySQL database and implementation of VC are simple

Source: Internet
Author: User

This article mainly describes how to install, debug, and implement the MySQL database with VC, to debug this Demo, You need to copy the mydb sub-directory in the directory to the data sub-directory of the installation directory of MySQL (the best combination with PHP.

My is: D: Program FilesMySQL (the best combination with PHP) MySQL (the best combination with PHP) Server 5.0 data

Abstract: This article describes in detail how to install and debug MySQL (the best combination with PHP), and how to compile with VC, to add, modify, and delete data.

Figure 1) "width =" 510 "height =" 417 "/>

OWASP elements enhance Web Application Security 2)

"Spoof" steals your wireless network neighbor

How to intrude into jsp (preferred for SUN Enterprise Applications) Websites

Hacker knowledge: how to hide PHP file Backdoors

Jsp (preferred for SUN enterprise-level applications) + javabean learning 2)

Java getting started video tutorial-lecture 61st

OWASP 10 elements enhance Web Application Security 1

What is an asp Trojan?

How to install Java in Windows Server 2003

Website security concerns in Web 2.0 JavaScript

I. Installation of MySQL (the best combination with PHP)

You can install MySQL (the best combination with PHP)-5.0.41-win32 at http://down.ddvip.com/view/11509967813389.html). Of course, you have a better version, note: select "full installation". Only in this way will the header files required for VC compilation be installed ). After the installation, the server configuration will be performed. You can set your server login password or not.

Ii. configuration of VC6.0

1) Open the Options Option Under the Tools menu in the VC6.0 toolbar, and select "Includefiles" from the "Show Directories for:" drop-down list on the right of the directories tab ", then add the include directory path for local MySQL installation (the best combination with PHP) to the list box in the middle. My D: Program FilesMySQL database MySQL (the best combination with PHP) Server 5.0 include ).

2) Select "Library files" in the "Show directories for:" drop-down list mentioned above, and then add the Lib directory path for your local installation of MySQL (best combination with PHP. The Lib directory contains two directories: debug and opt. We recommend that you select debug. My D: Program FilesMySQL (the best combination with PHP) MySQL (the best combination with PHP) Server 5.0 libdebug ).

3) Add "libMySQL (the best combination with PHP). lib" in "Project settings-> Link: Object/library modules ".

4) Add the following content to stdafx. h:

Baidu I post it Sina Weibo # include "MySQL (the best combination with PHP). h"

# Include "winsock. h"

# Pragma comment (lib, "libMySQL (best combination with PHP). lib ")

5) we recommend that you copy "libMySQL (the best combination with PHP). lib, libMySQL (the best combination with PHP). dll" to the directory of your project.

3. create databases and tables

Open "START-> All Programs-> MySQL (the best combination with PHP) server 5.0-> MySQL (the best combination with PHP) Command Line Client.exe ". If the password is not set, press enter and the system will prompt that the Server is successfully started.

MySQL (the best combination with PHP)> show databases; // display all DATABASES. Be sure to press ";" and press Enter.

MySQL (the best combination with PHP)> create database mydb; // create database mydb

MySQL (the best combination with PHP)> USE mydb; // select the database mydb you created

MySQL (best combination with PHP)> show tables; // display TABLES in the database

MySQL (best combination with PHP)> create table mytable (username VARCHAR (100), visitelist VARCHAR (200 ),

Remark VARCHAR (200); // create a table mytable: User Name; access list; Remarks

MySQL database> DESCRIBE mytable; // displays the table structure.

Iv. VC Programming

MySQL (the best combination with PHP); // database connection handle

MySQL (the best combination with PHP) _ init (& MySQL (the best combination with PHP ));

If (! MySQL (the best combination with PHP) _ real_connect (& MySQL (the best combination with PHP), "localhost", "root", NULL, "mydb", 3306, NULL, 0 ))

{// Mydb indicates the database you have created. 3306 is the port number and can be set by yourself.

AfxMessageBox ("database connection failed ");

Return FALSE;

}

1) Implement the Add function

CString strUsername, strList, strRemark, strSQL;

StrSQL. Format ("insert into mytable (username, visitelist, remark) values ('' % s', ''% s','' % s '')",

StrUsername, strList, strRemark); // be sure to write it in one row, and you must have ''''

If (the best combination of MySQL (and PHP) _ real_query (& MySQL database, (char *) (LPCTSTR) strSQL, (UINT) strSQL. GetLength ())! = 0 ){

AfxMessageBox ("failed to add ");

}

2) Implement the modification function CString strUsername, strList, strRemark, strSQL, str_PreName; // str_PreName is used to record the row to be modified. For details, see the source code.

StrSQL. Format ("update mytable set username ='' % s', visitelist = ''% s '',

Remark = ''% s' 'where username ='' % S' ", strUsername, strList, strRemark, str_PreName );

If (the best combination of MySQL and PHP) _ real_query (& MySQL (the best combination with PHP), (char *) (LPCTSTR) strSQL, (UINT) strSQL. getLength ())! = 0 ){

AfxMessageBox ("modification failed ");

}

3) Implement the delete function

CString strSQL;

StrSQL. Format ("delete from mytable where username ='' % S' ", str_PreName); // you must have ''''

If (the best combination of MySQL and PHP) _ real_query (& MySQL (the best combination with PHP), (char *) (LPCTSTR) strSQL, (UINT) strSQL. getLength ())! = 0 ){

AfxMessageBox ("deletion failed ");

}

4) read the table content to the CListCtrl control m_list

M_list.DeleteAllItems ();

Char * ch_query;

Ch_query = "select * from mytable ";

If (MySQL (the best combination with PHP) _ real_query (& MySQL (the best combination with PHP), ch_query, (UINT) strlen (ch_query ))! = 0 ){

AfxMessageBox ("Table errors in the Database ");

}

CString str;

MySQL (the best combination with PHP) _ RES * result;

MySQL (the best combination with PHP) _ ROW row;

If (! (Result = MySQL (the best combination with PHP) _ use_result (& MySQL (the best combination with PHP )))){

AfxMessageBox ("failed to read the dataset ");

}

Int I = 0;

While (row = MySQL (the best combination with PHP) _ fetch_row (result )){

Str. Format ("% s", row [0]);

M_list.InsertItem (I, str );

Str. Format ("% s", row [1]);

M_list.SetItemText (I, 1, str );

Str. Format ("% s", row [2]);

M_list.SetItemText (I, 2, str );

I ++;

}

MySQL database _ free_result (result );

5) shut down the database

MySQL (the best combination with PHP) _ close (& MySQL (the best combination with PHP); // it is best to write it to the OnDestroy () function.

V. Conclusion

Based on the work of several netizens, this article describes how to install and debug MySQL (the best combination with PHP) and how to compile it with VC, the "add, modify, delete" and other functions of data can be helpful to friends who are confused in the VC Programming of MySQL (the best combination with PHP, I would like to express my gratitude to several netizens!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.