1. 程式人生 > >C/C++連線MySql資料庫使用總結

C/C++連線MySql資料庫使用總結

本文對如何使用MySql的API連線MySql資料庫,開發環境為VS2008.

一、VS2008工程設定工作

首先,建立一個windows應用程式的工程,將C/C++->前處理器->前處理器定義下的_WINDOWS改為_CONSOLE,

image

將聯結器->系統->子系統 選擇為控制檯。

image

由於我們要使用Mysql的API,並且我們機子上肯定安裝了Mysql資料庫,所以我們要將工程的標頭檔案路徑指向Mysql安裝目錄的同文件mysql.h所在的位置,將連線庫路徑指向libmysql.lib所在的路徑,

在我的機子上,Mysql 的安裝路徑為:C:\Program Files\MySQL\MySQL Server 5.1

image

image

我們需要把VS2008的工程中的標頭檔案路徑和連線庫路徑指向上面的兩個地方:

將x專案屬性頁的C/C++->常規->附加包含目錄指向:C:\Program Files\MySQL\MySQL Server 5.1\include

image

將專案屬性頁的連結器->常規->附加庫目錄指向:C:\Program Files\MySQL\MySQL Server 5.1\lib\opt.

image

將連結器->輸入->附加依賴項中新增libmysql.lib。

image

如果不設定連結器->輸入->附加依賴項中新增libmysql.lib,那麼會出現如下的錯誤:

1>------ 已啟動全部重新生成: 專案: MySql-Connect, 配置: Debug Win32 ------ 
1>正在刪除專案“MySql-Connect”(配置“Debug|Win32”)的中間檔案和輸出檔案 
1>正在編譯... 
1>MySql_Connect.cpp 
1>x:\程式設計練習\c-c++\c\mysql_connect.cpp(35) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 
1>        d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : 參見“scanf”的宣告 
1>x:\程式設計練習\c-c++\c\mysql_connect.cpp(72) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 
1>        d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : 參見“sprintf”的宣告 
1>x:\程式設計練習\c-c++\c\mysql_connect.cpp(86) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 
1>        d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : 參見“sprintf”的宣告 
1>正在編譯資源清單... 
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1 
1>Copyright (C) Microsoft Corporation.  All rights reserved. 
1>正在連結... 
1>LINK : 沒有找到 d:\我的文件\Visual Studio 2008\Projects\MySql-Connect\Debug\MySql-Connect.exe 或上一個增量連結沒有生成它;正在執行完全連結 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號

[email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號
[email protected]
,該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>MySql_Connect.obj : error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 _main 中被引用 
1>d:\我的文件\Visual Studio 2008\Projects\MySql-Connect\Debug\MySql-Connect.exe : fatal error LNK1120: 10 個無法解析的外部命令 
1>生成日誌儲存在“file://d:\我的文件\Visual Studio 2008\Projects\MySql-Connect\MySql-Connect\Debug\BuildLog.htm” 
1>MySql-Connect - 11 個錯誤,3 個警告 
========== 全部重新生成: 成功 0 個,失敗 1 個,跳過 0 個 ==========

二、連線Mysql和從MySql中取出資料的API介紹

2.1 mysql_real_connect()

2.1.1 函式原型:

MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned int client_flag)

2.1.2 引數說明:

• 第一個引數應該是一個現存MYSQL結構的地址。在呼叫mysql_real_connect()之前,你必須呼叫mysql_init()初始化MYSQL結構。見下面的例子。

• host值可以是一個主機名或一個IP地址。如果host是NULL或字串"localhost",假定是到本地主機的一個連線。如果OS支援套接字(Unix)或命名管道(Win32),使用他們而不是TCP/IP與伺服器連線。

• user引數包含使用者的MySQL登入ID。如果user是NULL,假定是當前使用者。在Unix下,它是當前登入名。在Windows ODBC下,必須明確地指定當前使用者名稱字。見16.4 怎樣填寫ODBC管理程式中各種域。

• passwd引數為user包含口令。如果passwd是NULL,只有在user表中對於有一個空白口令欄位的使用者的條目將被檢查一個匹配。這允許資料庫主管設定MySQL許可權,使使用者獲得不同的口令,取決於他們是否已經指定一個口令。注意:不要試圖在呼叫mysql_real_connect()前加密口令;口令加密自動被客戶API處理。

• db是資料庫名。如果db不是NULL,連線將預設資料庫設定為這個值。

• 如果port不是0,值對於TCP/IP連線將用作埠號。注意host引數決定連線的型別。

• 如果unix_socket不是NULL,字串指定套接字或應該被使用的命名管道。注意host引數決定連線的型別。

• client_flag值通常是0,但是在很特殊的情況下可以被設定為下列標誌的組合:

標誌名字 意味著的標誌

CLIENT_FOUND_ROWS 返回找到的(匹配的)行數,不是受到影響的行數。

CLIENT_NO_SCHEMA 不允許db_name.tbl_name.col_name語法。這是為了ODBC;如果你使用該語法,導致語法分析器產生一個錯誤,它是為在一些ODBC程式捕捉錯誤是有用的。

CLIENT_COMPRESS 使用壓縮協議。

CLIENT_ODBC 客戶是一個ODBC客戶。這使mysqld變得對ODBC更友好。

2.1.3 返回值

如果連線成功,一個 MYSQL*連線控制代碼。如果連線失敗,NULL。對一個成功的連線,返回值與第一個引數值相同,除非你傳遞NULL給該引數。

2.1.4 錯誤

CR_CONN_HOST_ERROR

不能連線MySQL伺服器。

CR_CONNECTION_ERROR

不能連線本地MySQL伺服器。

CR_IPSOCK_ERROR

不能建立一個IP套接字。

CR_OUT_OF_MEMORY

記憶體溢位。

CR_SOCKET_CREATE_ERROR

不能建立一個Unix套接字。

CR_UNKNOWN_HOST

不能找到主機名的IP地址。

CR_VERSION_ERROR

由於試圖使用一個不同協議版本的一個客戶庫與一個伺服器連線導致的一個協議失配。如果你使用一個非常老的客戶庫連線一個沒有使用--old-protocol選項啟動的新伺服器,這就能發生。

CR_NAMEDPIPEOPEN_ERROR;

不能在 Win32 上建立一個命名管道。

CR_NAMEDPIPEWAIT_ERROR;

不能在 Win32 上等待一個命名管道。

CR_NAMEDPIPESETSTATE_ERROR;

不能在 Win32 上得到一個管道處理器。

2.2  mysql_select_db()

2.2.1 函式原型

int mysql_select_db(MYSQL *mysql, const char *db)

2.2.2 引數說明

使得由db指定的資料庫成為 在由mysql指定的連線上的預設(當前)資料庫。在隨後的查詢中,這個資料庫對於不包括一個顯式的資料庫指定符的表的引用是預設資料庫。

除非連線的使用者能被認證允許使用資料庫,否則mysql_select_db()失敗。

2.2.3 返回值

成功,零。如果發生一個錯誤,非零。

2.2.4  錯誤

CR_COMMANDS_OUT_OF_SYNC

命令以一個不適當的次序被執行。

CR_SERVER_GONE_ERROR

MySQL伺服器關閉了。

CR_SERVER_LOST

對伺服器的連線在查詢期間失去。

CR_UNKNOWN_ERROR

發生一個未知的錯誤。

2.3 mysql_real_query

2.3.1 函式原型

int mysql_real_query(MYSQL *mysql, const char *query, unsigned int length)

2.3.2 引數說明

執行由query指向的SQL查詢,它應該是一個length個位元組的字串。查詢必須由一個單個的SQL語句組成。你不應該在語句後增加一個終止的分號(“;”)或\g。

對於包含二進位制資料的查詢,你必須使用mysql_real_query()而不是mysql_query(),因為二進位制程式碼資料可能包含“\0”字元,而且,mysql_real_query()比mysql_query()更快,因為它對查詢字串呼叫strlen()。

2.3.3 返回值

如果查詢成功,零。如果發生一個錯誤,非零。

2.3.4  錯誤

CR_COMMANDS_OUT_OF_SYNC

命令以一個不適當的次序被執行。

CR_SERVER_GONE_ERROR

MySQL伺服器關閉了。

CR_SERVER_LOST

對伺服器的連線在查詢期間失去。

CR_UNKNOWN_ERROR

發生一個未知的錯誤。

2.4 mysql_store_result

2.4.1 函式原型

MYSQL_RES *mysql_store_result(MYSQL *mysql)

2.4.2 返回值

MYSQL_RES result structure with the results. NULL (0) if an error occurred.

2.5  mysql_fetch_row()

Description

Retrieves the next row of a result set. When used after mysql_store_result()mysql_fetch_row() returns NULLwhen there are no more rows to retrieve. When used after mysql_use_result()mysql_fetch_row() returns NULLwhen there are no more rows to retrieve or if an error occurred.

The number of values in the row is given by mysql_num_fields(result). If row holds the return value from a call tomysql_fetch_row(), pointers to the values are accessed as row[0] to row[mysql_num_fields(result)-1]NULL values in the row are indicated by NULL pointers.

The lengths of the field values in the row may be obtained by calling mysql_fetch_lengths(). Empty fields and fields containing NULL both have length 0; you can distinguish these by checking the pointer for the field value. If the pointer is NULL, the field is NULL; otherwise, the field is empty.

Return Values

MYSQL_ROW structure for the next row. NULL if there are no more rows to retrieve or if an error occurred.

Errors

Note that error is not reset between calls to mysql_fetch_row()

  • The connection to the server was lost during the query.

三、利用Mysql庫提供的API編寫連線Mysql和從Mysql中取出資料的程式碼

   1:  #include <windows.h>
   2:  #include "stdio.h"
   3:  #include "winsock.h" 
   4:  #include "mysql.h" 
   5:   
   6:   
   7:  int main()
   8:  {
   9:   
  10:  MYSQL * con; //= mysql_init((MYSQL*) 0); 
  11:  MYSQL_RES *res;
  12:  MYSQL_ROW row;
  13:   
  14:   
  15:  char tmp[400];
  16:   
  17:  //database configuartion
  18:  char dbuser[30]="root"; 
  19:  char dbpasswd[30]="apple";
  20:  char dbip[30]="localhost";
  21:  char dbname[50]="excel";
  22:  char tablename[50]="test";
  23:  char *query=NULL;
  24:   
  25:   
  26:  int x;
  27:  int y;
  28:  int rt;//return value
  29:  unsigned int t;
  30:   
  31:  int count = 0;
  32:   
  33:   
  34:  printf("input x,y\n");
  35:  scanf("%d,%d",&x,&y);
  36:  fflush(stdin);
  37:  printf("input over\n");
  38:  con = mysql_init((MYSQL*) 0); 
  39:   
  40:   
  41:  if ( con !=NULL && mysql_real_connect(con,dbip,dbuser,dbpasswd,dbname,3306/*TCP IP埠*/,NULL/*Unix Socket 連線型別*/,0/*執行成ODBC資料庫標誌*/) ) 
  42:  { 
  43:      if (!mysql_select_db(con,dbname)) 
  44:      { 
  45:          printf("Select successfully the database!\n"); 
  46:          
  47:          con ->reconnect = 1; 
  48:   
  49:          query = "set names \'GBK\'";
  50:          //mysql_query(con,"set names \'GBK\'"); 
  51:          
  52:          rt=mysql_real_query(con,query,strlen(query));
  53:          if (rt)
  54:          {
  55:              printf("Error making query: %s !!!\n",mysql_error(con));
  56:          }
  57:          else
  58:          {
  59:              printf("query %s succeed!\n",query);
  60:          }
  61:          
  62:      }
  63:  }
  64:   
  65:  else
  66:  {
  67:      MessageBoxA(NULL,"Unable to connect the database,check your configuration!","",NULL);
  68:   
  69:  }
  70:   
  71:      //sprintf(tmp,"update %s set 商品=\'%s\',賣出=%d,成交=%d,漲跌=%d,買進=%d,總量=%d,漲幅=%f,時間=\'%s\' where  %s",tablename,goods,sold,deal,fluctuate,buy,total,delta,time,UpdateCon);
  72:      sprintf(tmp,"insert into %s values(%s,%d,%d)",tablename,"null",x,y); //注意如何向具有自增欄位的資料庫中插入記錄
  73:      //MessageBoxA(NULL,tmp,tmp,MB_OK);
  74:      //mysql_query(con,tmp);
  75:   
  76:      rt=mysql_real_query(con,tmp,strlen(tmp));
  77:      if (rt)
  78:      {
  79:          printf("Error making query: %s !!!\n",mysql_error(con));
  80:      }
  81:      else
  82:      {
  83:          printf("%s executed!!!\n",tmp);
  84:      }
  85:      
  86:      sprintf(tmp,"select * from %s",tablename);
  87:      
  88:      rt=mysql_real_query(con,tmp,strlen(tmp));
  89:      if (rt)
  90:      {
  91:          printf("Error making query: %s !!!\n",mysql_error(con));
  92:      } 
  93:      else
  94:      {
  95:          printf("%s executed!!!\n",tmp);
  96:      }
  97:      
  98:      res = mysql_store_result(con);//將結果儲存在res結構體中
  99:   
 100:      while(row = mysql_fetch_row(res))  
 101:      {  
 102:          /** 
 103:          * MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); 
 104:           * 檢索行 
 105:          */  
 106:   
 107:         for(t=0;t<mysql_num_fields(res);t++)  
 108:          {  
 109:              printf("%s  ",row[t]);  
 110:          }  
 111:          printf(".............\n");  
 112:          count ++;
 113:      }  
 114:     printf("number of rows %d\n",count);
 115:      printf("mysql_free_result...\n");  
 116:      mysql_free_result(res);  
 117:   
 118:      mysql_close(con);
 119:      return 0;
 120:   
 121:  }

四、執行結果

image

五、資料庫指令碼

/*
Navicat MySQL Data Transfer

Source Server         : localhost
Source Server Version : 50141
Source Host           : localhost:3306
Source Database       : excel

Target Server Type    : MYSQL
Target Server Version : 50141
File Encoding         : 65001

Date: 2011-09-23 10:41:43
*/
   1:  SET FOREIGN_KEY_CHECKS=0;
   2:  -- ----------------------------
   3:  -- Table structure for `test`
   4:  -- ----------------------------
   5:  DROP TABLE IF EXISTS `test`;
   6:  CREATE TABLE `test` (
   7:    `x` bigint(4) NOT NULL AUTO_INCREMENT,
   8:    `y` int(4) DEFAULT NULL,
   9:    `z` int(4) DEFAULT NULL,
  10:    PRIMARY KEY (`x`)
  11:  ) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=latin1;
  12:   
  13:  -- ----------------------------
  14:  -- Records of test
  15:  -- ----------------------------
  16:  INSERT INTO `test` VALUES ('95', '12432', '4334');
  17:  INSERT INTO `test` VALUES ('96', '213', '321');
  18:  INSERT INTO `test` VALUES ('97', '213', '213');
  19:  INSERT INTO `test` VALUES ('98', '123', '231');
  20:  INSERT INTO `test` VALUES ('99', '321', '231');
  21:  INSERT INTO `test` VALUES ('100', '123', '32132');
  22:  INSERT INTO `test` VALUES ('101', '777', '32213');
  23:  INSERT INTO `test` VALUES ('102', '123', '213');
  24:  INSERT INTO `test` VALUES ('103', '21', '321');
  25:  INSERT INTO `test` VALUES ('104', '324', '432');
  26:  INSERT INTO `test` VALUES ('105', '132', '231');
  27:  INSERT INTO `test` VALUES ('106', '324', '342');
  28:  INSERT INTO `test` VALUES ('107', '23', '23');
  29:  INSERT INTO `test` VALUES ('108', '12', '21');
  30:  INSERT INTO `test` VALUES ('109', '231', '321');
  31:  INSERT INTO `test` VALUES ('110', '123', '231');
  32:  INSERT INTO `test` VALUES ('111', '123', '231');
  33:  INSERT INTO `test` VALUES ('112', '123', '123');
  34:  INSERT INTO `test` VALUES ('113', '312', '231');
  35:  INSERT INTO `test` VALUES ('114', '312', '321');
  36:  INSERT INTO `test` VALUES ('115', '23', '3');
  37:  INSERT INTO `test` VALUES ('116', '213', '312');
  38:  INSERT INTO `test` VALUES ('117', '2', '3');
  39:   
  40:  -- ----------------------------
  41:  -- Table structure for `xqdata`
  42:  -- ----------------------------
  43:  DROP TABLE IF EXISTS `xqdata`;
  44:  
            
           

相關推薦

簡單講一下C語言連線MySQL資料庫

1.首先你得將MySQL安裝上   apt-get install mysql-server  (mysql -uroot -p 登陸測試) 2.安裝連結庫   apt-get install libmysqlclient-dev 3.進行資料庫的建立,例如:   cre

Linux程式設計——C語言連線MySQL資料庫

MySQL是Linux系統下廣泛使用的開源免費資料庫,是Linux應用程式資料儲存的首選。許多釋出的Linux版本是自帶MySQL的,但是也有些釋出版本是不帶的(比如我現在用的Ubuntu),那就需要手動安裝。在Synaptic Packet Management中搜索“m

C語言連線MySQL資料庫

1 配置 win7 32bit,mysql5.5,vs2008 vc路徑設定,工具 -> 選項 -> 專案和解決方案 -> VC++ 路徑,Platform選擇Win32,然後 Include files中新增 D:\Program F

c#遠端連線mysql資料庫

,安裝好後,將MySQLDriverCS.dll通過新增引用的方式,新增到專案中。 2、設定mysql資料庫為允許遠端訪問,採用如下程式碼: 格式:grant 許可權 on 資料庫名.表名 使用者@登入主機 identified by "使用者密碼";grant selec

C# FluentNHibernate 連線mysql資料庫

首先需要安裝FluentNHibernate包,右鍵工程檔案 右鍵專案工程,如下圖,在開啟的視窗中下載NHibernate包,並安裝。 程式程式碼: 連線資料庫: using FluentNHibernate.Cfg; using Fluen

C api 連線mysql資料庫的 開發例項

1. 下載mysql c connector 安裝包; 有兩種方法:                  1 下載tar檔案, 將其中的的 lib, include , bin 都放在 /usr/local 相應的目錄下;                  2. 也可配置連

C/C++連線MySql資料庫使用總結

本文對如何使用MySql的API連線MySql資料庫,開發環境為VS2008. 一、VS2008工程設定工作 首先,建立一個windows應用程式的工程,將C/C++->前處理器->前處理器定義下的_WINDOWS改為_CONSOLE, 將聯結器->系統->子系統 選擇為控制檯。

vs2013下c++連線mysql資料庫

 本文使用的是mysql提供的api來進行連線,這樣使用比較方便。 開發環境:mysql 5.6+vs2013+win8.1作業系統 步驟1: 要使用mysql的api,需要mysql安裝目錄下include 和 lib 兩個資料夾的東西,如果你用的是wamp或者php

Linux下的C#連線Mysql資料庫

今天在嘗試在 Linux 系統下使用C#連線資料庫,發現網上這方面的資訊很少,所以就寫一篇部落格記錄一下。 Linux下這裡使用的是mono。 首先是缺少Mysql.Data.dll這個庫的,所以需要安裝 https://dev.mysql.com/downloads/connector/net/ 安

C++ API方式連線mysql資料庫實現增刪改查

轉自 http://www.bitscn.com/pdb/mysql/201407/226252.html 一、環境配置 1,裝好mysql,新建一個C++控制檯工程(從最簡單的弄起,這個會了,可以往任何c++工程移植),在vs2010中設定,工程--屬性--VC++目

採用C/S架構完成使用者註冊並連線Mysql資料庫(介面winform)

語言:C#開發平臺:VS2017對於C/S架構的一些基本互動我前面已經寫過了,這裡就不再贅述,C#並沒有直接連線資料庫的東西,需要匯入資料庫的外掛才能驅動資料庫操作,using MySql.Data.MySqlClient;也就是引如這個名稱空間,這個空間來自Mysql下的一

C語言操作MySQL資料庫,進行連線、插入、修改、刪除等操作

  很多人用到MySQL來開發一些專案,有時為了效能,我們會直接用C語言來開發相關的模組,尤其在我們的web應用中,雖然PHP、JSP等指令碼均提供了MySQL的介面,但是顯然直接使用C語言具有更好的安全性和效能,Michael以前用PHP開發的多個專案中就使用了C語言編寫的

解決C++連線MySQL資料庫插入和獲取記錄中文字元亂碼問題

字元編碼真是個頭痛的問題,以前一直不放在心上,現在用到了才發現真的麻煩。 花了將近一天的時間終於達到目的。 測試環境VS2015+MYSQL5.5,各種編碼的具體說明就不講了,自行百度。 1、讀取資料亂碼問題: vs專案下,預設編碼Unicode,但我的資料庫預設utf

C#連線MySQL資料庫,並建庫、建表

本文章是建立在已經安裝MySQL資料庫的前提,預設安裝在C:\Program Files (x86)\MySQL,建議在安裝時選中Connector.NET 6.9的安裝,裡面有MySQL與C#連線的動態連結庫。   幫助文件C:\Program Files (x86)\MySQL\Connec

linux下c++連線mysql資料庫

在Linux下,我們可以通過MySQL提供的C API連線資料庫。 使用C API連線mysql資料庫除了要安裝mysql-client和mysql-server,還需要安裝mysql的開發包mysql-devel。 我的系統是fedora,安裝命令如下:s

C++連線MySQL資料庫(利用API)

一般C/C++與資料庫相連有兩種方法。 利用ODBC,ADO,或者JDBC 用ODBC,ADO,JDBC等這些介面,利用裡面的方法來進行與資料庫的連線,簡化對資料庫的操作,方便對資料庫進行管理。 介面的區別可以參考以下文章 不過注意的是C/C++

c# 連線mysql資料庫

準備工作: 1.下載引用(mysql-connector-net-5.2.7-noinstall)並新增引用,只需要新增其中一個“mysql.data.dll”就行了 2.新增引用 接下來,新增下列程式碼到一個新建類,MySQLCon 記得將資料庫名字,密碼修改下

c#從100到題中隨機抽出20到題並進行判斷對錯連線mysql資料庫

工具:vs2012 資料庫mysql c#連線mysql需要下載mysql.data.dll檔案 private void Form1_Load(object sender, EventArgs e) { MySqlConnection myconn = null;

C++連線mysql資料庫的兩種方法(ADO連線mysql api連線)

【原文 http://www.jb51.net/article/44262.htm 】 現在正做一個介面,通過不同的連線字串操作不同的資料庫。要用到mysql資料庫,C++連線mysql有2種方法:利用ADO連線、利用mysql自己的api函式進行連線,下面看看如何用吧。

C++使用ADO連線MySql資料庫

1.資料庫技術發展 ODBC->DAO->RDO->ADOOLE DB 2.ADO中包含了七個物件成員          Connection用於管理資料庫的連線          Command包含sql命令          RecordSet用來儲