您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 同济大学数据库作业lab10
同济大学《数据库技术及应用》实验报告实验报告题目:对象访问数据库二姓名:学号:年级:专业:指导教师:日期:2014年10月27日一.实验目的1.学习用SQLcommand对象实现对数据库的访问2.熟练掌握vb.net访问数据库的多种方法二.实验内容(实验题目+运行界面截图+实现代码)1.完成学生成绩录入的功能界面设计ImportsSystem.Data.SqlClientPublicClassForm1PrivateSubForm1_Load(senderAsObject,eAsEventArgs)HandlesMyBase.LoadDimmysqlAsString=selectsnumfromstudentDimmyconnAsNewSqlConnection(database=university;datasource=.\SQLEXPRESS;integratedsecurity=true)DimmyadapterAsNewSqlDataAdapter(mysql,myconn)DimmydatasetAsNewDataSetmyadapter.Fill(mydataset,take)ComboBox1.DataSource=mydataset.Tables(0)ComboBox1.DisplayMember=snumEndSubPrivateSubComboBox1_SelectedIndexChanged(senderAsObject,eAsEventArgs)HandlesComboBox1.SelectedIndexChangedDimmysql2AsString=selectsecnumfromscwheresnum='&ComboBox1.Text&'DimmyconnAsNewSqlConnection(database=university;datasource=.\SQLEXPRESS;integratedsecurity=true)Dimmyadapter2AsNewSqlDataAdapter(mysql2,myconn)Dimmydataset2AsNewDataSetmyadapter2.Fill(mydataset2,take2)ComboBox2.DataSource=mydataset2.Tables(0)ComboBox2.DisplayMember=secnumEndSubPrivateSubButton1_Click(senderAsObject,eAsEventArgs)HandlesButton1.ClickDimmyconnAsNewSqlConnection(database=university;datasource=.\SQLEXPRESS;integratedsecurity=true)Dimmysql3AsString=insertintoscvalues('&ComboBox1.Text&','&ComboBox2.Text&','&ComboBox2.Text&',&Val(TextBox1.Text)&)DimmycmdAsNewSqlCommand(mysql3,myconn)myconn.Open()Trymycmd.ExecuteNonQuery()CatchexAsExceptionMsgBox(ex.Message)EndTrymyconn.Close()EndSubEndClass2.完成学生查询系统的功能界面设计ImportsSystem.Data.SqlClientPublicClassForm2PrivateSubForm2_Load(senderAsObject,eAsEventArgs)HandlesMyBase.LoadDimmysqlAsString=selectsnumfromstudentDimmyconnAsNewSqlConnection(database=university;datasource=.\SQLEXPRESS;integratedsecurity=true)DimmyadapterAsNewSqlDataAdapter(mysql,myconn)DimmydatasetAsNewDataSetmyadapter.Fill(mydataset,take)ComboBox1.DataSource=mydataset.Tables(0)ComboBox1.DisplayMember=snumEndSubPrivateSubComboBox1_SelectedIndexChanged(senderAsObject,eAsEventArgs)HandlesComboBox1.SelectedIndexChangedDimmysql2AsString=selectstudent.sname,count(secnum)ass1,avg(score)ass2fromstudent,scwherestudent.snum=sc.snumgroupbystudent.snameDimmyconnAsNewSqlConnection(database=university;datasource=.\SQLEXPRESS;integratedsecurity=true)Dimmyadapter2AsNewSqlDataAdapter(mysql2,myconn)Dimmydataset2AsNewDataSetmyadapter2.Fill(mydataset2,take2)TextBox1.Text=mydataset2.Tables(0).Rows(0).Item(0)TextBox2.Text=mydataset2.Tables(0).Rows(0).Item(1)TextBox3.Text=mydataset2.Tables(0).Rows(0).Item(2)EndSubEndClass三.实验体会或收获(有感而发,没有体会也可以不写)
本文标题:同济大学数据库作业lab10
链接地址:https://www.777doc.com/doc-1847152 .html