VC,,实验报告

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验报告

班级:网络z091

学号:094552

姓名:李丹

一、

1.

2.

二、

1.

2.

三、

1. 实验目的掌握数据库的基本知识、odbc程序设计掌握列表框和组合框控件实验

内容在vc++6.0中编写程序数据库应用程序基本设计和购物表设计编程序数据库

cstring m_chax;

⑴初始化:

{

m_list.insertcolumn(0,num); m_list.insertcolumn(1,sex); m_list.insertcolumn(2,age); m_list.insertcolumn(3,wage); m_list.setcolumnwidth(0,100); m_list.setcolumnwidth(1,100); m_list.setcolumnwidth(2,100); m_list.setcolumnwidth(3,100); m_set.open(afx_db_use_default_type,sql);//打开记录集

int i=0;

while(!m_set.iseof())

{

m_list.insertitem(i,m_set.m_num); m_list.setitemtext(i,1,m_set.m_sex); cstring str;

str.format(%d,m_set.m_age); m_list.setitemtext(i,2,str); m_list.setitemtext(i,3,m_set.m_wage); m_set.movenext();

i++;

}

m_set.close();

}

⑵“添加”调出新对话框(idd_dialog1)

及成员变量(cstring m_num; int m_sex; cstring m_wage; int m_age;)

{

if(dlg.domodal()==idok)

{

m_set.open(afx_db_use_default_type,null); m_set.addnew(); m_set.m_num=dlg.m_num;

if(dlg.m_sex==0)

m_set.m_sex=男;

else

m_set.m_sex=女;

m_set.m_age=dlg.m_age;

m_set.m_wage =dlg.m_wage;

m_set.update();

m_set.close();

}

}

⑶“删除”

{

int i=m_list.getselectionmark(); if(i<0)

this->messagebox(先选取记录); else

{

cstring xnum1;

char xnum[10];

int x=m_list.getitemtext(i,0,xnum,10); xnum1.format(%s,xnum);

m_set.close();

}

}

⑷“浏览”

{

m_list.deleteallitems();

m_set.open(afx_db_use_default_type,sql); int i=0; while(!m_set.iseof()) m_list.insertitem(i,m_set.m_num); m_list.setitemtext(i,1,m_set.m_sex); cstring str;

str.format(%d,m_set.m_age); m_list.setitemtext(i,2,str); m_list.setitemtext(i,3,m_set.m_wage); m_set.movenext();

i++;

}

m_set.close();

}

⑸“修改”

{

int i=m_list.getselectionmark(); if(i<0)

{

this->messagebox(先选取记录); return;

}

cstring xnum0,xnum1;

char xnum[10];

int x=m_list.getitemtext(i,0,xnum,10); xnum1.format(%s,xnum);

dlg.m_num=xnum1;

xnum0=xnum1;

dlg.m_age=m_set.m_age;

dlg.m_wage=m_set.m_wage;

if(m_set.m_sex==男)

dlg.m_sex=0;

else

dlg.m_sex=1;

dlg.domodal();

m_set.edit();

m_set.m_num=dlg.m_num;

m_set.m_age=dlg.m_age;

m_set.m_wage=dlg.m_wage;

if(dlg.m_sex==0)

m_set.m_sex=男; m_set.m_sex =女;

m_set.update();

m_set.close();

}

⑹“查询”

{

this->updatedata();

cstring sql;

if(m_set.iseof())

{

afxmessagebox(error);

return ;

}

m_list.deleteallitems();

int i=0;

while(!m_set.iseof())

{

m_list.insertitem(i,m_set.m_num); m_list.setitemtext(i,1,m_set.m_sex);

相关文档
最新文档