Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

VC++ Á¬½ÓMySQL Êý¾Ý¿â

°Ñmysql.h¸´ÖƵ½vcµÄĿ¼µÄincludeĿ¼ÏÂ
mysql.hÔÚÄãmysqlµÄ°²×°Ä¿Â¼ÏµÄincludeÀïÃæÈç:mysql\include
°Ñlibmysql.lib(ÔÚmysqlµÄ°²×°Ä¿Â¼Ï£¬ËÑË÷ϾÍÄÜÕÒµ½£©¸´ÖƵ½Õâ¸öĿ¼Ï£¨C:\Program Files\Microsoft Visual Studio 9.0\VC\lib£©£¬Òª²»Á¬½Ó»á³ö´í¡£
Èç¹û±àÒëÁ¬½Óʱ»¹Êdzö´í¡£¾Í°Ñlibmysql.lib¸´ÖƵ½ÄãÔ´³ÌÐòµÄĿ¼ÖÐ
£¨Ê¾Àý1)¡¢
// TODO: Add your control notification handler code here
char *query;
int t,r;
MYSQL_RES *res;
MYSQL_ROW row;
m_mysql = mysql_init(NULL);
if (!mysql_real_connect(m_mysql,"localhost","databasename",
"yourdatabase-password","yourtable",0,NULL,0))
{
CString errors =mysql_error(m_mysql);
MessageBox(errors,"´íÎó");
}

query="select text from yourtable";
t=mysql_real_query(m_mysql,query,(unsigned int) strlen(query));
if(t)
{

MessageBox(mysql_error(m_mysql));
}

res=mysql_use_result(m_mysql);
row=mysql_fetch_row(res);
CString sumstr;
for(r=0;r<=mysql_field_count(m_mysql);r++)
{
if(row<0)
{
MessageBox("error");
}
for(t=0;t<mysql_num_fields(res);t++)
{
CString Query = row[t];
sumstr+=Query+" ";
}

}
MessageBox(sumstr);
mysql_close(m_mysql);

}
£¨Ê¾Àý2£©¡¢
#include "winsock.h"
#include "mysql.h"
int main(int argc, char* argv[])
{
MYSQL * con = mysql_init((MYSQL*) 0);
LPSTR host = "***";
LPSTR user,psw,dbname,;
if ( con !=NULL
&& mysql_real_connect(con,host,user,psw,dbname,3306,NULL,0) )
{
if (!mysql_select_db(con,dbname))
{
printf("Select successfully the database!\n");
con ->reconnect = 1;
if (!mysql_query(con,"select * from table_name"))
{
printf("Show table---orders:\n");
MYSQL_RES * recordSet = mysql_store_result(con);
long j = mysql_num_fields(recordSet);
long i = (long)mysql_num_


Ïà¹ØÎĵµ£º

ʹÓÃÓαêʵÏÖ mysql ´æ´¢¹ý³ÌÖеÄÑ­»·

create   procedure   all_joiner_message(   in   captions   varchar(255),  in contents text,   in objectid int, in types int  ,  out count int)
begin
 declare   userids   int;
 DECLARE _done IN ......

mysqlºÍsqlserverÖв鿴µ±Ç°¿âÖÐËùÓбíºÍ×Ö¶ÎÐÅÏ¢

>>mysql:
1¡¢²é¿´ËùÓбíÃû£º
show tables [from db_name];
2¡¢²é¿´×Ö¶ÎÐÅÏ¢
SHOW FULL COLUMNS from db_name.table_name
»ñÈ¡ÒÔÏÂÐÅÏ¢
Field £º×Ö¶ÎÃû
Type£º×Ö¶ÎÀàÐÍ
Collation£º×Ö·û¼¯ £¨mysql 5.0ÒÔÉÏÓУ©
Null £ºÊÇ·ñ¿ÉÒÔΪNULL
Key£ºË÷Òý£¨PRI,unique,index)
Default£ºÈ±Ê¡Öµ
Extra£º¶îÍ⣨ÊÇ·ñ aut ......

mysql,sqlserver,oracleÈýÖÖÊý¾Ý¿âµÄ´ó¶ÔÏó´æÈ¡


mysql ´ó¶ÔÏó´æÈ¡:
ÀàÐÍÒ»°ãÓ¦¸ÃÓÃmediumblod,
blobÖ»ÄÜ´æ2µÄ16´Î·½¸öbyte,
mediumblodÊÇ24´Î·½,
Ò»°ãÀ´Ëµ¹»ÓÃÁË.longblobÊÇ32´Î·½ÓÐЩ´ó.
MYSQLĬÈÏÅäÖÃÖ»ÄÜ´æ1M´óСµÄÎļþ,ÒªÐÞ¸ÄÅäÖÃ,WIN°æ±¾µÄÔÚmysql.iniÎļþÖÐ
ÐÞ¸Ämax_allowed_packet,net_buffer_lengthµÈ¼¸¸ö²ÎÊý,»òÖ±½ÓSET GLOBAL varName=value.
linux°æ± ......

C/C++Í·ÎļþÒ»ÀÀ


C¡¢´«Í³ C++

#include <assert.h>¡¡¡¡¡¡¡¡
//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡
//×Ö·û´¦Àí
#include <errno.h>¡¡¡¡¡¡¡¡
//¶¨Òå´íÎóÂë
#include <float.h>¡¡¡¡¡¡¡¡
//¸¡µãÊý´¦Àí
#include <fstream.h>¡¡¡¡¡¡
//ÎļþÊäÈ룯Êä³ö
#include <iomanip.h>¡¡ ......

C/C++³ÌÐòÔ±³£¼ûÃæÊÔÌâÉîÈëÆÊÎö


1.ÒýÑÔ   ±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº­¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û-¡£
 Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Êý¶¼¿É¿´³öÃæÊÔÕßÔÚ¼¼ÊõÉϾ¿¾¹´ïµ½Á ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ