关于MySQL的C++/MFC编程
1项目环境搭建
1、 使用VS2008编译工具
2、 安装mysql-essential-5.1.47-win32.msi
3、 安装mysql-connector-odbc-5.1.7-win32.msi
4、 安装navicat8lite_mysql_cs.exe
2 MySQL数据创建
1.1数据脚本制作
下面创建数据库的表:分别是(SCHOOL)学校,(COLLEGE)学院,(PROFESSIONAL)专业,(CLASS)班级,(STUDENT)学生,(COURSE)分数。
/*-------------------------------------------------------*/
/* DBMS name: MySQL5.1 */
/* Created on: 2012-8-4 9:02:00 */
/*-------------------------------------------------------*/
drop table if exists T_BAS_SCHOOL;
drop table if exists T_BAS_COLLEGE;
drop table if exists T_BAS_PROFESSIONAL;
drop table if exists T_BAS_CLASS;
drop table if exists T_BAS_STUDENT;
drop table if exists T_BAS_COURSE;
/*-------------------------------------------------------*/
/* Table: T_BAS_SCHOOL */
/*-------------------------------------------------------*/
create table T_BAS_SCHOOL
(
ID int not nullauto_increment,
szName text not null,
szAddress text not null,
szPhone text not null,
iReserve int default 0,
szReserve text defaultNULL,
primary key (ID)
);
/*-------------------------------------------------------*/
/* Table: T_BAS_COLLEGE */
/*-------------------------------------------------------*/
create table T_BAS_COLLEGE
(
ID int not nullauto_increment,
szName text not null,
iShoolID int not null,
iReserve int default 0,
szReserve text defaultNULL,
primary key (ID)
);
/*-------------------------------------------------------*/
/* Table: T_BAS_PROFESSIONAL */
/*-------------------------------------------------------*/
create table T_BAS_PROFESSIONAL
(
ID int not nullauto_increment,
szName text not null,
iCollegeID int not null,
iReserve int default 0,
szReserve text defaultNULL,
primary key (ID)
);
/*-------------------------------------------------------*/
/* Table: T_BAS_CLASS */
/*-------------------------------------------------------*/
create table T_BAS_CLASS
(
ID int not nullauto_increment,
szName text not null,
iProfessionalID int not null,
iReserve int default 0,
szReserve text defaultNULL,
primary key (ID)
);
/*-------------------------------------------------------*/
/* Table: T_BAS_STUDENT */
/*-------------------------------------------------------*/
create table T_BAS_STUDENT
(
ID int not null auto_increment,
szName text not null,
iClassID int not null,
iReserve int default 0,
szReserve text defaultNULL,
primary key (ID)
);
/*-------------------------------------------------------*/
/* Table: T_BAS_COURSE */
/*-------------------------------------------------------*/
create table T_BAS_COURSE
(
ID int not null,
szName text not null,
primary key (ID)
);
1.2 数据创建
使用NavicatLite for MySQL将脚本导入,注意字符选择。