同济大学SQL数据库实验8

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

Imports System.Data.SqlClient

Public Class Form1

Dim mybind As New BindingSource

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim myconn As New SqlConnection("initial catalog=university;data

source=jd299;integrated security=true;")

Dim mydata As String = "select * from student"

Dim adapter As New SqlDataAdapter(mydata, myconn)

Dim dataset As New DataSet

adapter.Fill(dataset, "list")

mybind.DataSource = dataset

mybind.DataMember = "list"

TextBox1.DataBindings.Add(New Binding("text", mybind, "snum", True))

TextBox2.DataBindings.Add(New Binding("text", mybind, "sname", True))

TextBox3.DataBindings.Add(New Binding("text", mybind, "sex", True))

TextBox4.DataBindings.Add(New Binding("text", mybind, "telephone", True))

TextBox5.DataBindings.Add(New Binding("text", mybind, "birthday", True))

TextBox6.DataBindings.Add(New Binding("text", mybind, "dept", True))

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

mybind.AddNew()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

mybind.MoveFirst()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

mybind.MovePrevious()

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

mybind.MoveNext()

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

mybind.MoveLast()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

mybind.RemoveAt(mybind.Position)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim myconn As New SqlConnection("initial catalog=university;data

source=jd299;integrated security=true;")

Dim mydata As String = "select * from student"

Dim adapter As New SqlDataAdapter(mydata, myconn)

Dim dataset As New DataSet

adapter.Fill(dataset, "list")

mybind.DataSource = dataset

mybind.DataMember = "list"

mybind.EndEdit()

adapter.Update(dataset.Tables("list"))

End Sub

End Class

Imports System.Data.SqlClient

Public Class Form1

Dim mybindres As New BindingSource

Dim myconn As New SqlConnection("initial catalog=university;data source=jd305;integrated security=true;")

Dim mysql As String= "select student.snum,sname,cname,score from student,sc,sections,course where student.snum=sc.snum and sc.secnum=sections.secnum and um=um "

Dim myadapter As New SqlDataAdapter(mysql, myconn)

Dim mydataset As New DataSet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

myadapter.Fill(mydataset, "list")

mybindres.DataSource = mydataset

mybindres.DataMember = "list"

TextBox1.DataBindings.Add(New Binding("text", mybindres, "snum", True))

TextBox2.DataBindings.Add(New Binding("text", mybindres, "sname", True))

TextBox3.DataBindings.Add(New Binding("text", mybindres, "cname", True))

TextBox4.DataBindings.Add(New Binding("text", mybindres, "score", True)) End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

mybindres.MoveFirst()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

mybindres.MovePrevious()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

mybindres.MoveNext()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

mybindres.MoveLast()

End Sub

End Class

相关文档
最新文档