- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
这是精心收集的精品经典资料,值得下载保存阅读!
c语言操作mysql数据库小例子_互帮互助(C language MySQL database operation example _ mutual help)
C language MySQL database operation example _ help Baidu home page | Baidu space | login help home page blog album | personal files | friends
View Article
C language operation MySQL database small example, 2008-07-15 09:30 Author: yds_amber
Database statement
Create database student
Create, table, stu
Id int (4) auto_increment,
SnO varchar (20),
Sname varchar (30)
Primary key (ID)
)
Insert, into, Stu, values (nullyds_amber)
C language source file example.c
#include stdio.h
#include unistd.h
#include stdlib.h
#include string.h
#include /usr/include/mysql/mysql.h / * on the can view the previous article.
#define SQL2 select, sname, from, Stu, where, id =%d
Int main (int, argc, char, **argv) {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
Int, len, i;
Char *server= localhost;
Char *user= root;
Char *password= 860925;
Char *database= student;
Char sqlbuf[160];
Char *sql= select * from stu;
Char *sql3= insert, into, Stu, values (nullrhl).;
Char *sql4= update, Stu, set, sname=yds, where, id=1.;
If (argc = = 2) {
Fprintf (stderr, need, one, parameter, for, select:id, \n\n);
Exit (1);
}
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_real_query (Conn, SQL, strlen (SQL)) {
Fprintf (stderr,%s\n, mysql_error (conn));
Exit (1);
}
If ((res=mysql_store_result (conn)) {
Fprintf (stderr, Couldnt, get, result, from,%s\n,
Mysql_error (conn);
Exit (1);
}
How many columns for return / * * /.
Len=mysql_num_fields (RES);
Printf (number, of, fields,%d\n, returned:, len);
Printf (number of rows returned:%d\n, mysql_num_rows (RES));
While (row=mysql_fetch_row (RES))
{
For (i=0; ilen; i++)
Printf (%s, row[i]);
Printf (\n);
}
The release of the result set memory / * * /
Mysql_free_result (RES);
Parameterized query / * * /
Sprintf (sqlbuf, SQL2, ATOI (argv[1])); / * tectonic
您可能关注的文档
- 2009初中生物会考复习提纲(2009 junior high school biology examination outline).doc
- 2010年1月份全国近代史纲要真题及答案(In 2010 January the national modern history Zhenti and answers).doc
- 2010年中考历史总复习测试题(最新版)(2010 review of the history exam questions (the latest edition)).doc
- 2010年7月近代史(Modern history of July 2010).doc
- 2010年cctv元宵晚会的主持词(2010 CCTV Lantern Festival presided over the words).doc
- 2010年1月《中国近现代史纲要》真题答案(一)(In January 2010 the outline of the history of modern Chinese Zhenti answer (a)).doc
- 2010年周庄景区活动安排(2010 Zhouzhuang scenic activities arrangements).doc
- 2010年厦门市第十六届职工技术比赛电子设备装接工(技师)项目竞赛规则(Competition rules of electronic equipment installation (technician) project for sixteenth employees' technical competition in Xiamen in 2010).doc
- 2010年外国文学复习题(Review of foreign literature in 2010).doc
- 2010年天津市中考 化学试题(Chemistry examination questions of Tianjin middle school in 2010).doc
- c语言机试题库50道编程题答案(C language test questions database, 50 programming questions answer).doc
- c语言期末必考40题(C language study 40 final questions).doc
- c语言界面(C language interface).doc
- c语言程序设计,选择结构程序设计实验(C language programming, selection of structural programming experiments).doc
- c语言图形编程(三、绘图函数1)(C programming language graphics (three, drawing function 1)).doc
- c语言程序设计试题(C language programming questions).doc
- c语言编程课后训练20道题(C language programming, after-school training 20 questions).doc
- c语言编译全过程(C language compilation process).doc
- c语言编译常见错误(Common errors in C language compilation).doc
- c语言编译的过程(The process of compiling a C language).doc
文档评论(0)