您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 同济大学数据库作业lab9
同济大学《数据库技术及应用》实验报告实验报告题目:使用ado.net访问数据库姓名:学号:年级:专业:指导教师:日期:2014年10月27日一.实验目的1.掌握vb访问数据库的方法2.学习sqlconnection,sqldataadpter,dataset对象的基本编程方法二.实验内容(实验题目+运行界面截图+实现代码)1.设计如下成绩查询功能界面ImportsSystem.Data.SqlClientPublicClassForm2PrivateSubButton1_Click(senderAsObject,eAsEventArgs)HandlesButton1.ClickDimmysqlAsString=selectcnameas'课程名',scoreas'分数'fromstudent,sc,sections,coursewherestudent.snum=sc.snumandsc.secnum=sections.secnumandsections.cnum=course.cnumandstudent.snum='&TextBox1.Text.Trim&'DimmyconnAsNewSqlConnection(database=university;datasource=jd35\SQLEXPRESS;integratedsecurity=true)DimmyadapterAsNewSqlDataAdapter(mysql,myconn)DimmydatasetAsNewDataSetmyadapter.Fill(mydataset,take_list)DataGridView1.DataSource=mydataset.Tables(take_list)DimsqlAsString=selectsnamefromstudentwheresnum='&TextBox1.Text.Trim&'Dimmyadapter1AsNewSqlDataAdapter(sql,myconn)Dimmydataset1AsNewDataSetmyadapter1.Fill(mydataset1,take)Label3.Text=mydataset1.Tables(take).Rows(0).Item(0).ToString&选修课成绩EndSubPrivateSubLabel4_Click(senderAsObject,eAsEventArgs)HandlesLabel4.ClickEndEndSubEndClass2.交互式数据绑定查询ImportsSystem.Data.SqlClientPublicClassForm1DimmybindAsBindingSourcePrivateSubButton1_Click(senderAsObject,eAsEventArgs)HandlesButton1.ClickDimmysqlAsString=selectstudent.snum,sname,cname,scorefromstudent,sc,sections,coursewherestudent.snum=sc.snumandsc.secnum=sections.secnumandsections.cnum=course.cnumandstudent.snum='&TextBox1.Text.Trim&'DimmyconnAsNewSqlConnection(database=university;datasource=jd35\SQLEXPRESS;integratedsecurity=true)DimmyadapterAsNewSqlDataAdapter(mysql,myconn)DimmydatasetAsNewDataSetmyadapter.Fill(mydataset,take)TextBox2.Text=mydataset.Tables(take).Rows(0).Item(0).ToStringTextBox3.Text=mydataset.Tables(take).Rows(0).Item(1).ToStringTextBox4.Text=mydataset.Tables(take).Rows(0).Item(2).ToStringTextBox5.Text=mydataset.Tables(take).Rows(0).Item(3).ToStringmybind.DataSource=mydatasetmybind.DataMember=takeEndSubPrivateSubButton2_Click(senderAsObject,eAsEventArgs)HandlesButton2.Clickmybind.MoveFirst()EndSubPrivateSubButton3_Click(senderAsObject,eAsEventArgs)HandlesButton3.Clickmybind.MovePrevious()EndSubPrivateSubButton4_Click(senderAsObject,eAsEventArgs)HandlesButton4.Clickmybind.MoveNext()EndSubPrivateSubButton5_Click(senderAsObject,eAsEventArgs)HandlesButton5.Clickmybind.MoveLast()EndSubEndClass三.实验体会或收获(有感而发,没有体会也可以不写)
本文标题:同济大学数据库作业lab9
链接地址:https://www.777doc.com/doc-5423595 .html