Implementation and Application of MySQL database interface VC (1) _ MySQL

Source: Internet
Author: User
Introduction with the development of modern computer software and hardware and network technology, searching for information on the Internet has become one of the most important methods to . As we all know, all online information is stored in the website database. the functions of such operations are provided by the database server. Obviously, the performance of the database server is directly related to the survival of the website. Introduction
With the development of modern computer software and hardware and network technology, searching for information on the Internet has become one of the most important methods to  As we all know, all online information is stored in the website database. the functions of such operations are provided by the database server. Obviously, the performance of the database server is directly related to the survival of the website. The most frequently used database servers in website construction are oracle and MySQL. The former is powerful and belongs to the flagship database server, but it has invested too much in the early stage. The latter features are constantly improved, easy to use, and without losing performance, and can be obtained for free. Therefore, MySQL is used for database servers of many small and medium websites. In addition, MySQL is also used for some large websites due to its outstanding performance.
  
It can be seen that the performance of the MySQL database server in website construction is outstanding. However, because of this, few people use MySQL for application software development. This article will introduce in detail the application of different interfaces of MySQL database server in VC environment, and finally generate a CDatabase class to encapsulate the MySQL database interface function.
  
Computer environment for database interface implementation and application: hardware, C466, 128 M, 15G; software and operating system, visual c ++ 6.0, MySQL 3.23.22-beta for win32, WIN98.
  
   1. MySQL database overview
MySQL is a real multi-user, multi-thread SQL database server. SQL (Structured Query Language) is the world's most popular and standardized database language. it makes it easier to store, update, and access information. MySQL is the implementation of a client/server structure. it consists of a server daemon mysqld and many different client programs and libraries.
  
MySQL is designed to be fast, robust, and easy to use. It was initially because the founder of MySQL needed such an SQL server that could process large databases on an order of magnitude with any manufacturers providing databases on non-expensive hardware platforms, but the speed was faster, mySQL is developed as a result.
  
It provides APIs for C, C ++, JAVA (JDBC), Perl, Python, PHP and TCL. it supports multiple platforms, including Solaris, SunOS, BSDI, sgi irix, AIX, dec unix, Linux, FreeBSD, SCO OpenServer, NetBSD, OpenBSD, HPUX, Win9x and NT; diverse data types, including/unsigned 1, 2, 3, 4, 8-byte integers, FLOAT, DOUBLE, CHAR, VARCHAR, TEXT, BLOB, DATE, DATETIME, YEAR, SET, ENUM; flexible and secure permission system, password encryption; provides ODBC interfaces for Windows, access can be used to connect to the table. a third-party developer provides a variety of ODBC drivers. in MySQL 3.23, the maximum table size of MyISAM can be 8 million TB (2 ^ 63 bytes ); supported in multiple languages, but not in Chinese.
  
However, for fast, robust, and easy-to-use purposes, MySQL must sacrifice some flexible and powerful functions, such as subqueries, stored procedures and triggers, foreign keys, and transaction processing. Therefore, MySQL lacks flexibility in some applications, but it also makes it faster to process data than other database servers at least 2 ~ 3 times.
  
MySQL itself does not support Windows graphical interface, therefore, all the database operations and management functions can only be completed in the MS-DOS mode. First, you must log on to the MySQL server, that is, enter MySQL-H host-U user-Ppassword at the prompt \ MYSQL \ BIN>. if the prompt is changed to mysql>, the login is successful. Then, select the database to be operated on, that is, mysql> USE databasename. Then you can use the SQL statement to query. To exit the database server, run the QUIT command to exit the server.
  
Of course, due to the increasing popularity of MySQL, many third-party software companies have released a graphical interface support software for MySQL in Windows, for example, EMS mysql manager of EMS company provides the MySQL database operation function in Windows format.
  
   2. use ODBC APIs to call MySQL database functions
ODBC (Open Database Connectivity) is an Open Database Interconnection. as an important part of the Windows Open structure, it is already familiar to many Windows programmers. ODBC depends on the drivers provided by Database manufacturers, when using ODBC APIs, the Windows ODBC management program passes database access requests to the correct driver, and the driver then uses SQL statements to indicate the DBMS (database management system) therefore, the existence of ODBC provides us with powerful capabilities and flexibility to develop database applications. In Windows, you can install an ODBC database for multiple databases to connect to the database and access their data.
  
For MySQL database server, its manufacturer also provides the corresponding ODBC driver, the latest version of which is the myodbc-2.50.31-win95. After installation in the WIN98 environment, you can use the programming language to perform operations supported by ODBC on the MySQL database through the odbc api. Because ODBC shields the differences between various databases, the program originally used to operate other databases can also perform operations on the MySQL database through ODBC. That is to say, ODBC improves the universality of the program to the database.
  
To program a MySQL database through the odbc api using VC, you must set the MySQL data source:
  
Then we can program the MySQL database according to the general ODBC database programming method.

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.