ʹÓÃC²Ù×÷MySQLÊý¾Ý¿â£¨vs 2008£©
×î½ü¼¸ÌìÏÐÀ´ÎÞÊ£¬±ã³¢ÊÔÁËÒ»ÏÂÓÃC²Ù×÷Êý¾Ý¿â£¬ÏÂÃæ±ãÊÇÎÒ²âÊԵľßÌå½á¹û£º
¿ª·¢»·¾³ÊÇwindows 7 ultimate(Ó¢ÎÄ°æ) IDE ÊÇvs 2008 professional ÖÐÎÄ°æ,Êý¾Ý¿âÊÇmysql 5.1
Ê×ÏÈ£¬ÎÒÔÚMySQL¿âÖд´½¨ÁËÒ»¸ötest±í£º
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`age` int(3) DEFAULT NULL,
`gender` char(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8
È»ºó£¬ÒªÅäÖúÃvs 2008ϵĿª·¢»·¾³£º
¹¤¾ß->Ñ¡Ïî->ÏîÄ¿ºÍ½â¾ö·½°¸->vc++Ŀ¼
1. ÔÚ´°¿ÚÓÒ±ßÌí¼Ó°üº¬Îļþ£¨ÎÒµÄÊÇD:\Program Files\MySQL\MySQL Server 5.1\include£©
2.Ìí¼Ó¿âÎļþ£¨D:\Program Files\MySQL\MySQL Server 5.1\lib\opt£©
ÅäÖúú󣬼´¿É´´½¨ÐµĹ¤³ÌÁË¡£ÏÂÃæ±ãÊÇÎҵIJâÊÔ´úÂ룬עÊͱȽÏÏêϸ£¬ÎÒÕâÀï¾Í²»×ö¹ý¶àµÄ½éÉÜÁË¡£
×¢ÊÍ´ó¶àÊý¶¼ÊÇÎÒ·ÒëÁËÓ¢ÎÄÎĵµ£¬Ó¢ÎĺõĿÉÒÔÖ±½Ó²Î¿¼MySQLµÄ¹Ù·½Îĵµ¡£
MySQL¹ÙÍø£ºwww.mysql.com
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include "mysql.h"
//·Ç³£ÖØÒª
#pragma comment(lib, "libmysql.lib")
using namespace std;
int main() {
MYSQL *mysql;
MYSQL_RES *result;
MYSQL_ROW row;
unsigned int field_count;
unsigned int num_fields;
my_ulonglong affected_rows;
const char* selectString = "SELECT name,age,gender from test";
const char* updateString = "UPDATE test SET age=30 WHERE id=4";
const char* deleteString = "DELETE from test WHERE id=4";
const char* insertString = "INSERT INTO test VALUES(null,'zhaoliu',24,'m')";
const char* mutilExecution = "INSERT INTO test VALUES(null,'zhaoliu',24,'m');DELETE from test WHERE id=4";
/*
MYSQL *mysql_init(MYSQL *mysql)
º¯ÊýÃèÊö£º
·ÖÅä»ò³õʼ»¯Ò»¸öÊʺÏmysql_real_connect()º¯ÊýµÄMYSQL¶ÔÏó¡£Èç¹ûmysqlÊÇ¿ÕÖ¸Õ룬Ôòº¯Êý·ÖÅä²¢³õʼ»¯
Ò»¸öеÄMYSQL¶ÔÏó£¬×÷Ϊ·µ»ØÖµ·µ»Ø¡£·ñÔò£¬Ö±½Ó³õʼ»¯¶ÔÏ󣬲¢·µ»Ø¶ÔÏóµÄµØÖ·¡£Èç¹ûÓÃmysql_init()º¯Êý
³õʼ»¯ÁËÒ»¸öеĶÔÏó£¬ÔòÔÚµ÷ÓÃmysql_clos
Ïà¹ØÎĵµ£º
update article set body = (REPLACE(body, '</div>', ' ')) where typeid=21
ÓÃupdateºÍreplaceÔÚmysqlÖÐÌ滻ijһ¸ö×ֶεIJ¿·ÖÄÚÈÝ
update users_settings set `ConfigValue` = replace(configvalue,' fromstr' 'tostr') where `ConfigName`='accesslist'
¶ÔÓÚÕë¶Ô×Ö·û´®Î»ÖõIJÙ×÷£¬µÚÒ»¸öλÖñ»±ê¼Ç ......
130 £ºÎļþ¸ñʽ²»ÕýÈ·¡££¨»¹²»ÊǺÜÇå³þ´íÎóµÄ×´¿ö£©
145 £ºÎļþÎÞ·¨´ò¿ª¡£
1005£º´´½¨±íʧ°Ü¡£
1006£º´´½¨Êý¾Ý¿âʧ°Ü¡£
1007£ºÊý¾Ý¿âÒÑ´æÔÚ£¬´´½¨Êý¾Ý¿âʧ°Ü¡£
1008£ºÊý¾Ý¿â²»´æÔÚ£¬É¾³ýÊý¾Ý¿âʧ°Ü¡£
1009£º²»ÄÜɾ³ýÊý¾Ý¿âÎļþµ¼ÖÂɾ³ýÊý¾Ý¿âʧ°Ü¡£
1010£º²»ÄÜɾ³ýÊý¾ÝĿ¼µ¼ÖÂɾ³ýÊý¾Ý¿âʧ°Ü¡£
1011£ºÉ ......
C/C++Êý×éÃûÓëÖ¸ÕëÇø±ðÉî²ã̽Ë÷
×÷ÕߣºËᦻª e-mail:21cnbao_AT_21cn.com [AT -> @]
1. ÒýÑÔ
Ö¸ÕëÊÇC/C++ÓïÑÔµÄÌØÉ«£¬¶øÊý×éÃûÓëÖ¸ÕëÓÐÌ«¶àµÄÏàËÆ£¬ÉõÖÁºÜ¶àʱºò£¬Êý×éÃû¿ÉÒÔ×÷ΪָÕëʹÓá£ÓÚÊǺõ£¬ºÜ¶à
³ÌÐòÉè¼ÆÕ߾ͱ»¸ãºýÍ¿ÁË¡£¶øÐí¶àµÄ´óѧÀÏʦ£¬ËûÃÇÔÚC ÓïÑԵĽÌѧ¹ý³ÌÖÐÒ²´íÎóµÃ¸øѧÉú½²½â£º“Êý ......
C/C++ÖеÄÈÕÆÚºÍʱ¼ä time_tÓëstruct tmת»»
ͻ񻣼
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê×¼Ê ......