新手遇到问题,请VB高手帮忙!
Sub 科室别类查询()Dim mysqlstr As String = "select * from 科室信息表"
Dim myconn As SqlConnection = New SqlConnection(connstr)
Dim myadapter As SqlDataAdapter = New SqlDataAdapter(mysqlstr, myconn)
Dim mydata As New DataSet
myconn.Open()
myadapter.Fill(mydata, "科室信息表")
DataGridViewX1.DataSource = mydata
DataGridViewX1.DataMember = "科室信息表"
Dim mydbinding1 As Binding = New Binding("text", mydata, "科室信息表.编号")
Dim mydbinding2 As Binding = New Binding("text", mydata, "科室信息表.室项")
Text编号.DataBindings.Add(mydbinding1)
Text室项.DataBindings.Add(mydbinding2)
这是修改按钮代码
Private Sub But修改_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles But修改.Click
Dim sqlstr As String = "update 科室信息表 set 室项='" & Text室项.Text & "' where 编号='" & Text编号.Text & "'"
Dim i As Integer = 0
Dim myconn As New SqlConnection(connstr)
Dim mycommd As New SqlCommand(sqlstr, myconn)
myconn.Open()
i = mycommd.ExecuteNonQuery()
If i > 0 Then
MsgBox("修改数据成功", MsgBoxStyle.OkOnly, "消息框")
Else
MsgBox("修改数据失败", MsgBoxStyle.OkOnly, "消息框")
End If
科室别类查询()
myconn.Close()
End Sub