同济大学SQL数据库实验9

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

Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New SqlConnection("DataBase=university;Data Source=jd311;Integrated
Security=True;")
Dim b As String= "select student.snum,cname,score from student,sc,section,course where sc.snum=student.snum and sc.secnum=section.secnum and um=um and
student.snum='" & TextBox1.Text.Trim & "'"
Dim adapter As New SqlDataAdapter(b, a)
Dim dataset As New DataSet
adapter.Fill(dataset, "list")
DataGridView1.DataSource = dataset.Tables("list")
Dim c As String = "select sname from student where snum='" & TextBox1.Text.Trim & "'" mandText = c
adapter.Fill(dataset, "sname")
Label2.Text = dataset.Tables("sname").Rows(0).Item(0).ToString & " 选修课程成绩 "
End Sub
End Class
2.Imports System.Data.SqlClient
Public Class Form1
Dim bind As New BindingSource
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
bind.MoveFirst()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
bind.MovePrevious()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
bind.MoveNext()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
bind.MoveLast()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New SqlConnection("DataBase=university;Data Source=jd311;Integrated
Security=True;")
Dim b As String= "select student.snum,sname,cname,score from student,sc,section,course where sc.snum=student.snum and sc.secnum=section.secnum and um=um and student.snum='" & TextBox1.Text.Trim & "'"
Dim adapter As New SqlDataAdapter(b, a)
Dim dataset As New DataSet
adapter.Fill(dataset, "list")
bind.DataSource = dataset
bind.DataMember = "list"
TextBox2.DataBindings.Add(New Binding("text", bind, "snum", True))
TextBox3.DataBindings.Add(New Binding("text", bind, "sname", True))
TextBox4.DataBindings.Add(New Binding("text", bind, "cname", True))
TextBox5.DataBindings.Add(New Binding("text", bind, "score", True)) End Sub
End Class。

相关文档
最新文档