亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C連接Mysql數(shù)據(jù)庫代碼

 更新時間:2013年11月12日 16:46:45   作者:  
使用C語言連接Mysql數(shù)據(jù)庫的方法,大家可以看看

復(fù)制代碼 代碼如下:
//vc工具中添加E:\WAMP\BIN\MYSQL\MYSQL5.5.8\LIB 路徑 
 //在工程設(shè)置-》鏈接》庫模塊中添加 libmysql.lib  
#include <stdio.h> 
#include <time.h> 
#include <string.h> 
#include <winsock.h> 
#include "E:\wamp\bin\mysql\mysql5.5.8\include\mysql.h" 
void main(){  
       MYSQL *conn;  
       MYSQL_RES *res;  
       MYSQL_ROW row;  
       char *server ="localhost";  
       char *user ="root";  
       char *password="";  
       char *database="test";  
       char sql[1024]="select * from chinaren";  
       conn=mysql_init(NULL);  

       if(!mysql_real_connect(conn,server,user,password,database,0,NULL,0)){  
               fprintf(stderr,"%s\n",mysql_error(conn));  
               exit(1);  
       }  

       if(mysql_query(conn,sql)){  
               fprintf(stderr,"%s\n",mysql_error(conn));  
               exit(1);  
       }  

       res=mysql_use_result(conn);  

       while((row = mysql_fetch_row(res))!=NULL){  
               printf("%s\n",row[2]);  
       }  

       mysql_free_result(res);  
       mysql_close(conn);  
}

相關(guān)文章

最新評論