版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上南昌航空大学信息工程学院 数据库原理 课程实验报告 实验名称: 学生成绩信息管理系统实验时间: 2010年月2日指导教师: 班 级 : 学 号 : 姓 名 : 成 绩 : 一、实验目的(1) 通过完成从用户需求分析、系统概要设计、系统详细设计以及数据库的SQL操作具体实现等全过程,把前面的各个实验更好地综合起来.(2) 进一步理解和掌握教材中的相关内容。(3) 掌握分析和设计一个大型数据库系统的基本思路与方法。二、 实验要求1. 独立完成该系统的数据库设计。2. 用SQL实现数据库的设计,并在MS SQL Server上调试通过。3. 写出查询、更新以及建立触发器SQ
2、L语句和执行结果。4. 掌握报表的使用。三、实验内容综合前面各章内容设计并调试一学生成绩管理系统,Delphi作为前台开发工具,SQL Server完成后台数据库存管理。创建学生成绩的统计(包括求班级各科成绩的平均分);并实现对各科成绩等的录入、修改、删除、查询等功能;实现学生成绩的统计(包括求班级各科成绩的平均分);并实现对各科成绩的排序。四、实验代码及功能注释用户登陆界面实验程序:procedure TForm1.Button1Click(Sender: TObject);用户登陆var ret:integer;beginadoconnection1.Open;with ADOStored
3、Proc1 dobeginClose;ProcedureName:='proc_login'Parameters.Clear;Parameters.Refresh;Parameters.ParamByName('username').Value:= Edit1.text;Parameters.ParamByName('password').Value:= Edit2.text;ExecProc;ret:= Parameters.ParamByName('return_value').Value;end;if ret=1 then
4、/用户名密码匹配beginshowmessage('登陆成功');form3.show;endelseshowmessage('你不是用户,请注册');end ;procedure TForm1.Button2Click(Sender: TObject);若不是用户,触发用户登陆界面显示beginform2.show;end;procedure TForm1.Button3Click(Sender: TObject);退出该管理系统beginform1.Close;end;说明:在这里,使用了adostoredproc1控件和adoconnection1控件,它
5、们的connectionstring属性都要与所设计的数据库相连,在查询分析器中,要运行存储过程如下:CREATE procedure proc_loginusername varchar(20),password varchar(20)asdeclare result intselect result=count(*) from users where username=username and passwords=passwordif result=0return 0return 1GO用户注册界面实验程序:procedure TForm2.Button1Click(Sender: TOb
6、ject);新用户注册begin adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('insert into users(username,passwords,核对密码,性别,出生年月,联系地址,联系电话,邮政编码,电子邮箱)'+'values(:1,:2,:3,:4,:5,:6,:7,:8,:9)'); adoquery1.parameters.parambyname('1').value:=''+edit1.text+'' adoquery1.par
7、ameters.parambyname('2').value:=''+edit2.text+'' adoquery1.parameters.parambyname('3').value:=''+edit3.text+'' adoquery1.parameters.parambyname('4').value:=''+combobox1.text+'' adoquery1.parameters.parambyname('5').value
8、:=''+combobox1.text+' '+combobox1.text+'' adoquery1.parameters.parambyname('6').value:=''+edit4.text+'' adoquery1.parameters.parambyname('7').value:=''+edit5.text+'' adoquery1.parameters.parambyname('8').value:=''
9、;+edit6.text+'' adoquery1.parameters.parambyname('9').value:=''+edit7.text+'' adoquery1.execsql;end;说明:在该数据库中,建了一个名为users的用户表,存储用户的信息。只有是用户在登陆时,才能进入主界面,当不是用户在登陆时,必须先进行新用户注册,才能进入主系统。 系统主界面学生基本信息查询精确查询程序:procedure TForm3.Button1Click(Sender: TObject);beginwith adoquery1
10、 dobegin if radiobutton1.Checked then /通过单选按钮的选择来判断是要进行精确查询还是模糊查询 begin adoquery1.Close ; adoquery1.SQL.Clear ; adoquery1.SQL.Add('select * from 学生表 where 学号='''+edit1.text+'''' ); adoquery1.Open; end;end;说明:由于学生表中,学号为主键,因此要查此表中学生基本信息,只要输入主键值即可得一条记录,即实现精确查询。模糊查询程序:pro
11、cedure TForm3.Button3Click(Sender: TObject);begin with adoquery1 do begin if radiobutton2.Checked then begin if (edit2.Text <>'')or (edit3.Text <>'')or(edit4.Text <>'')or(edit5.Text <>'') or(edit6.Text <>'')then begin adoquery1.Cl
12、ose; adoquery1.SQL.Clear; adoquery1.SQL.Add('select * from 学生表'); adoquery1.SQL.Add('where(学号 like '''+'%'+edit2.text+'%'+''')'); adoquery1.SQL.Add('or(姓名 like '''+'%'+edit3.text+'%'+''')'); adoqu
13、ery1.SQL.Add('or(所在系别 like '''+'%'+edit4.text+'%'+''')'); adoquery1.SQL.Add('or(所在专业 like '''+'%'+edit5.text+'%'+''')'); adoquery1.SQL.Add('or(所在班级 like '''+'%'+edit6.text+'%
14、39;+''')'); adoquery1.Open ; end else begin application.MessageBox('没有查询条件','提示',mb_ok); exit; end; end; end;end;说明:当输入的信息不是主键时,由于满足该输入条件的记录可能不只一个,因此得到的是一个模糊查询的结果。学生成绩查询方法与学生基本信息查询一致。学生基本信息录入实验程序:procedure TForm4.Button1Click(Sender: TObject);begin adoquery1.close; ad
15、oquery1.sql.clear; adoquery1.sql.add('insert into 学生表(学号,姓名,民族,出生年月,籍贯,性别,所在系别,所在专业,所在班级,政治面貌,家庭住址,邮政编码,联系电话)'+'values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13)'); adoquery1.parameters.parambyname('1').value:=''+edit1.text+'' adoquery1.parameters.parambyname
16、('2').value:=''+edit2.text+'' adoquery1.parameters.parambyname('3').value:=''+edit3.text+'' adoquery1.parameters.parambyname('4').value:=''+combobox1.text+' '+combobox2.text+'' adoquery1.parameters.parambyname('5'
17、;).value:=''+edit4.text+'' adoquery1.parameters.parambyname('6').value:=''+combobox3.text+'' adoquery1.parameters.parambyname('7').value:=''+combobox4.text+'' adoquery1.parameters.parambyname('8').value:=''+edit5.text+
18、39;' adoquery1.parameters.parambyname('9').value:=''+edit6.text+'' adoquery1.parameters.parambyname('10').value:=''+edit7.text+'' adoquery1.parameters.parambyname('11').value:=''+edit8.text+'' adoquery1.parameters.parambynam
19、e('12').value:=''+edit9.text+'' adoquery1.parameters.parambyname('13').value:=''+edit10.text+'' adoquery1.execsql;end;在SQL Server中查看录入结果录入前:录入后:说明:从录入前与录入后表的比较看到,实现了学号为aaa学生基本信息的录入。求学生平均成绩、成绩排序并显示实验程序:procedure TForm3.Button4Click(Sender: TObject);begi
20、n with adoquery1 dobegin if radiobutton3.Checked then与学生基本信息查询一样,这里为成绩精确查询 beginadoquery1.Close ; adoquery1.SQL.Clear ; adoquery1.SQL.Add('select * from 成绩信息表 where 学号='''+edit9.text+'''' ); adoquery1.Open; end; if radiobutton4.Checked then与学生基本信息查询一样,这里为成绩模糊查询 begin
21、if (edit10.text <>'')or (edit11.Text <>'')or(edit12.Text <>'')or(edit13.Text <>'') or(edit14.Text <>'')then begin adoquery1.Close; adoquery1.SQL.Clear; adoquery1.SQL.Add('select * from 成绩信息表'); adoquery1.SQL.Add('where
22、(学号 like '''+'%'+edit10.text+'%'+''')'); adoquery1.SQL.Add('or(姓名 like '''+'%'+edit11.text+'%'+''')'); adoquery1.SQL.Add('or(所在系别 like '''+'%'+edit12.text+'%'+''')&
23、#39;); adoquery1.SQL.Add('or(所在专业 like '''+'%'+edit13.text+'%'+''')'); adoquery1.SQL.Add('or(所在班级 like '''+'%'+edit14.text+'%'+''')'); adoquery1.Open ; end else begin application.MessageBox('没有查询条件
24、9;,'提示',mb_ok); exit; end; end; if radiobutton9.Checked then求每个学生的课程平均成绩 begin adoquery1.Close ; sql.Clear ; sql.Add('select 学号,姓名,AVG(成绩) as 平均成绩 from 成绩信息表 where 所在班级='''' group by 学号,姓名'); adoquery1.Open ; end; if radiobutton11.Checked then将学生成绩按从低到高排序 begin adoque
25、ry1.Close ; sql.Clear ; sql.Add('select 学号,姓名,avg(成绩) as 平均成绩 from 成绩信息表 group by 学号,姓名 order by 平均成绩'); adoquery1.open; end;end;end;求平均成绩界面与平均成绩排序后界面:说明:使用到了数据库的自带函数avg() 来求平均成绩,按平均成绩排序时,只要在已经做好的平均成绩显示程序上加上order by 语句即可。学生基本信息删除与修改实验程序:procedure TForm3.Button6Click(Sender: TObject);begin wi
26、th adoquery1 do begin if radiobutton7.Checked then begin adoquery1.Close ; adoquery1.SQL.Clear ; adoquery1.SQL.Add('update 学生表 set '+combobox1.text+'='''+edit19.text+''''); /edit19 编辑框用来输入要更改的字段名 adoquery1.SQL.Add('where 学号='''+edit18.text+''''); adoquery1.execsql; end; if radiobutton8.Checked then begin adoquer
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《我的母亲》专题阅读练习及答案
- 激发早期阅读兴趣 培养幼儿自主阅读能力
- 混凝土小型空心砌块砌体工程技术交底
- 干挂石材专项施工方案
- 干工程-这些流程你必须牢记
- 干部任免审批表样表
- “环梦之旅一见倾‘新’”迎新策划书
- 高中化学第十五周期末综合测评-高二化学人教版(2019)选修一每周一测
- 上海市浦东新区南片联合体2025年初三练习题五(全国I卷)数学试题含解析
- 陕西省西安市周至县2024-2025学年招生伯乐马模拟考试(三)数学试题含解析
- 大学复学申请表
- 教务处查课制度
- 老师您辛苦了(教师节)-主题班会课件(共45张PPT)
- 幼儿园校车消毒记录表
- 消防安全远程监控系统管理暂行规定
- 电力设施维保服务方案
- 森林防火测试题【附答案】
- 肩袖损伤的护理ppt课件
- 初二道德与法治(统编)我与社会
- OMRONE5CN数字式温度控制仪使用说明书
- 雨水管道非开挖修复工程施工方案
评论
0/150
提交评论