注册 登录
编程论坛 VB.NET论坛

新手遇到问题,请VB高手帮忙!

zw2864076 发布于 2008-10-22 17:02, 1111 次点击
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
4 回复
#2
zw28640762008-10-22 17:05
请高手,帮我指出问题,在什么地方,我是新手,很多地方不懂,最好能给我修改一下代码,先谢谢了,
#3
zw28640762008-10-24 09:02
大家帮我顶起来啊,
#4
bygg2008-10-24 12:29
修改后重新绑定一下数据
#5
zw28640762008-10-24 14:02
回复 4# bygg 的帖子
就是不知道修改以后,重新邦定数据啊,能不能帮我上面的代码修改一下.
1