Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ADO to connect to a MySQLl database in ADO VC++

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

The purpose of this article is to share with you how to use ADO to connect to MySQLl database in classic VC++. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

There are many ways to develop MySQL database applications through VC:

First, through the MyODBC interface

Second, through the Connector/C++l interface

Third, through the MySQL C API interface

Fourth, the third-party encapsulated MySQL class

After repeated comparison, I still chose MySQL C API to develop MySQL.

The steps to use MySQL in VC are as follows:

1. Download the server / client installation package for MySQL

The official download address is as follows:

Http://www.mysql.com/downloads/mysql-4.0.html

Since my development environment is Windows, I downloaded MySQL for Windows V4.0.12

2. Install MySQL server / client package

In general, just choose the next step.

By default, MySQL is installed under C:\ mysql.

3. Set up its development environment in VC

[options / projects / VC directory]

a. Set the include path to c:\ mysql\ include

b. Set the reference path to c:\ mysql\ include

c. Set the library path to c:\ mysql\ lib\ debug

[project Properties]

d. Set the linker-input-attach dependency to libmySQL.lib

e. Add the following line to the stdafx.h:

# include

# include "mysql.h"

4. At this point, you can use C API functions for development.

FAQ:

1. If there is an error that cannot use the type defined by mysql.h, you can regenerate the project.

two。 If there is a link error, copy the libmySQL.dll file to the current directory of the project.

MySQL provides a number of functions to manipulate the database, which can be roughly divided into the following categories:

The first part

Control class function

Mysql_init () initializes the MySQL object

Mysql_options () sets connection options

Mysql_real_connect () connects to the MySQL database

Mysql_real_escape_string () legalizes the query string

Mysql_query () issues a query string that ends with an empty character.

Mysql_real_query () issues a query string

Mysql_store_result () transmits the result at one time

Mysql_use_result () sends the result line by line

Mysql_free_result () releases the result set

Mysql_change_user () changes the user

Mysql_select_db () changes the default database

Mysql_debug () sends debugging information

Mysql_dump_debug_info () dumps debugging information

Mysql_ping () tests whether the database is active

Mysql_shutdown () request database SHUTDOWN

Mysql_close () closes the database connection

Part II

Information acquisition class function

Mysql_character_set_name () gets the default character set

Mysql_get_client_info () gets client information

Mysql_host_info () gets host information

Mysql_get_proto_info () gets the protocol information

Mysql_get_server_info () gets server information

Mysql_info () gets the additional information of some query statements

Mysql_stat () gets the database status

Mysql_list_dbs () gets the list of databases

Mysql_list_tables () gets the list of data tables

Mysql_list_fields () gets the list of fields

Part III

Row and column operation function

Mysql_field_count () gets the number of fields

Mysql_affected_rows () gets the number of affected rows

Mysql_insert_id () gets the ID value of the AUTO_INCREMENT column

Mysql_num_fields () gets the number of fields in the result set

Mysql_field_tell () gets the current field location

Mysql_field_seek () location field

Mysql_fetch_field () gets the current field

Mysql_fetch_field_direct () gets the specified field

Mysql_frtch_fields () gets an array of all fields

Mysql_num_rows () gets the number of rows

Mysql_fetch_lengths () gets the line length

Mysql_row_tell () gets the current line position

Mysql_row_seek () line positioning

Mysql_data_seek () line positioning

Mysql_fetch_row () gets the current line

The fourth part

Thread class operation function

Mysql_list_processes () returns a list of all threads

Mysql_thread_id () gets the current thread ID

Does mysql_thread_safe () support threading?

Mysql_kill () kills a thread

The fifth part

Error handling class function

Mysql_errno () gets the error number

Mysql_error () gets the error message

The above is how to use ADO to connect to MySQLl database in classic VC++. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report