您正在看的C语言教程是:C连MYSQL。用C连MYSQL及其简单操作的示例
1、数据库名:test,表名:PAY(工资表),结构如下:
CREATE TABLE PAY (
FNUMBER varchar(6) NOT NULL default '',
FNAME varchar(50) default NULL,
FSEX varchar(10) NOT NULL default '',
FAGE int(3) default NULL,
FPAY decimal(7,2) NOT NULL default '0.00',
PRIMARY KEY (FNUMBER)
) TYPE=MyISAM;
2、数据如下:
INSERT INTO PAY VALUES ('000001', 'Jack', 'men', 25, '5000.00');
INSERT INTO PAY VALUES ('000002', 'Aaron', 'men', 30, '7000.00');
INSERT INTO PAY VALUES ('000003', 'Ruth', 'women', 22, '4000.00');
INSERT INTO PAY VALUES ('000004', 'Tom', 'men', 28, '7200.00');
INSERT INTO PAY VALUES ('000005', 'Pearson', 'men', 20, '4000.00');
3、源程序如下(c_mysql.c):
#include "stdio.h"
#include "stdlib.h"
#include "mysql.h"
#define HOST "127.0.0.1"
#define USER "root"
#define PASSWORD "654321"
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载