เขียนโปรแกรม vb2010 เรียกข้อมูลในตารางDataGridViewเพื่อมาแก้ไข ข้อมูลRadioButtonไม่แสดงคะ ควรเขียนแก้ยังไง
Private Sub DataGridView1_DoubleClick(sender As Object, e As System.EventArgs) Handles DataGridView1.DoubleClick
Dim Con As New SqlConnection(ConStr)
Con.Open()
Dim MySQL As String
MySQL = "Select * From HospitalRadio Where HospitalID = @ID"
Dim Cmd As New SqlCommand(MySQL, Con)
Cmd.Parameters.Add("ID", SqlDbType.Int).Value = DataGridView1.CurrentRow.Cells(0).Value
Dim MyReader As SqlDataReader
MyReader = Cmd.ExecuteReader
While MyReader.Read()
If MyReader.HasRows Then
GroupBox1.Enabled = True
TextBox10.Text = MyReader("HospitalID")
TextBox1.Text = MyReader("HospitalName")
ComboBox2.Text = MyReader("HospitalDistrict")
ComboBox1.Text = MyReader("HospitalProvince")
TextBox4.Text = MyReader("RadioName")
TextBox5.Text = MyReader("RadioGeneration")
TextBox6.Text = MyReader("RadioNamber")
TextBox7.Text = MyReader("HosPerson")
TextBox8.Text = MyReader("HosNote")
If MyReader("RadioSystem") = "VHF/FM" Then
RadioButton1.Checked = True
End If
If MyReader("RadioSystem") = "HF/SSB" Then
RadioButton2.Checked = True
End If
End If
End While
Con.Close()
End Sub
เขียนโปรแกรม vb2010 เรียกข้อมูลในตารางDataGridViewเพื่อมาแก้ไข ข้อมูลRadioButtonไม่แสดงคะ ควรเขียนแก้ยังไง
Private Sub DataGridView1_DoubleClick(sender As Object, e As System.EventArgs) Handles DataGridView1.DoubleClick
Dim Con As New SqlConnection(ConStr)
Con.Open()
Dim MySQL As String
MySQL = "Select * From HospitalRadio Where HospitalID = @ID"
Dim Cmd As New SqlCommand(MySQL, Con)
Cmd.Parameters.Add("ID", SqlDbType.Int).Value = DataGridView1.CurrentRow.Cells(0).Value
Dim MyReader As SqlDataReader
MyReader = Cmd.ExecuteReader
While MyReader.Read()
If MyReader.HasRows Then
GroupBox1.Enabled = True
TextBox10.Text = MyReader("HospitalID")
TextBox1.Text = MyReader("HospitalName")
ComboBox2.Text = MyReader("HospitalDistrict")
ComboBox1.Text = MyReader("HospitalProvince")
TextBox4.Text = MyReader("RadioName")
TextBox5.Text = MyReader("RadioGeneration")
TextBox6.Text = MyReader("RadioNamber")
TextBox7.Text = MyReader("HosPerson")
TextBox8.Text = MyReader("HosNote")
If MyReader("RadioSystem") = "VHF/FM" Then
RadioButton1.Checked = True
End If
If MyReader("RadioSystem") = "HF/SSB" Then
RadioButton2.Checked = True
End If
End If
End While
Con.Close()
End Sub