如何将数据从文本框更新到SQL?

时间:2014-04-14 12:05:05

标签: sql-server vb.net

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        cn.Open()
        Try
            cmd.CommandText = "UPDATE Patient_Detail SET (Name ='" & TextBoxName.Text & "',Age = '" & TextBoxAge.Text & "',Sex = '" & TextBoxSex.Text & "',Address = '" & TextBoxAddress.Text & "',Check_In = '" & TextBoxCHiN.Text & "',Check_In_Illness = '" & TextBoxCHinL.Text & "',Sevice = '" & TextBoxService.Text & "',Check_out_Illness = '" & TextBoxCHoutL.Text & "',Check_out = '" & TextBoxCHout.Text & "',Transfer = '" & TextBoxTransfer.Text & "',Patient_result = '" & ComboBoxPtr.Text & "') WHERE ID = '" & TextBoxid.Text & "' "
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        cn.Close()
    End Sub
End Class

0 个答案:

没有答案