導航:首頁 > 編程大全 > c窗體程序連接資料庫

c窗體程序連接資料庫

發布時間:2025-01-09 17:57:09

❶ 用C語言怎麼實現與資料庫的連接

#include<mysql/mysql.h>

#include<stdio.h>

intmain()

{

MYSQL*conn;

MYSQL_RES*res;

MYSQL_ROWrow;

char*server="localhost";//本地連接

char*user="root";//

char*password="525215980";//mysql密碼

char*database="student";//資料庫名

char*query="select*fromclass";//需要查詢的語句

intt,r;

conn=mysql_init(NULL);

if(!mysql_real_connect(conn,server,user,password,database,0,NULL,0))

{

printf("Errorconnectingtodatabase:%s ",mysql_error(conn));

}else{

printf("Connected... ");

}

t=mysql_query(conn,query);

if(t)

{

printf("Errormakingquery:%s ",mysql_error(conn));

}else{

printf("Querymade... ");

res=mysql_use_result(conn);

if(res)

{

while((row=mysql_fetch_row(res))!=NULL)

{

//printf("num=%d ",mysql_num_fields(res));//列數

for(t=0;t<mysql_num_fields(res);t++)

printf("%8s",row[t]);

printf(" ");

}

}

mysql_free_result(res);

}

mysql_close(conn);

return0;

}

(1)c窗體程序連接資料庫擴展閱讀

C語言使用注意事項:

1、指針是c語言的靈魂,一定要靈活的使用它:

(1)、指針的聲明,創建,賦值,銷毀等

(2)、指針的類型轉換,傳參,回調等

2、遞歸調用也會經常用到:

(1)、遞歸遍歷樹結構

(2)、遞歸搜索

閱讀全文

與c窗體程序連接資料庫相關的資料

熱點內容
一個文件內容替換另一個文件 瀏覽:288
ios8最好的版本 瀏覽:400
錄屏決定文件大小的是什麼 瀏覽:322
數據用不了是哪裡壞掉了 瀏覽:310
百度網盤文件傳輸格式 瀏覽:455
蘋果系統txt文件 瀏覽:629
家裝網站怎麼設計 瀏覽:202
adc指令微程序 瀏覽:487
名片模板word 瀏覽:635
怎麼把文件夾上鎖 瀏覽:331
我不會英語怎麼編程 瀏覽:895
c盤和文件大小 瀏覽:63
maya工具架怎麼調出來 瀏覽:191
文件系統壞了怎麼辦 瀏覽:261
小公司網路布線 瀏覽:515
怎麼用二維碼編程 瀏覽:341
f9b文件能用手機看嗎 瀏覽:364
手機暴風視頻文件夾 瀏覽:394
vsftpdlinux下載文件 瀏覽:948
文件名修改後快捷方式還可以用嗎 瀏覽:387

友情鏈接