7 | Display column's stages from the database into ComboBox's Stage - VB.NET & SQL Server
- Using cmd As New SqlCommand("SELECT ID,stage FROM tbl_stages WHERE status='Available'", con)
Private Sub frm_Register_New_Student_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim con As New SqlConnection(conString)
Dim dtstages As New DataTable
dtstages.Clear()
con.Open()
Using cmd As New SqlCommand("SELECT ID,stage FROM tbl_stages WHERE status='Available'", con)
cmd.CommandType = CommandType.Text
cmd.CommandTimeout = 420
dtstages.Load(cmd.ExecuteReader)
If dtstages.Rows.Count <> 0 Then
cbox_stage.DataSource = dtstages
cbox_stage.DisplayMember = "stage"
cbox_stage_id.DataSource = dtstages
cbox_stage_id.DisplayMember = "ID"
con.Close()
Else
con.Close()
End If
End Using
End Sub
Private Sub frm_Register_New_Student_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim con As New SqlConnection(conString)
Dim dtstages As New DataTable
dtstages.Clear()
con.Open()
Using cmd As New SqlCommand("SELECT ID,stage FROM tbl_stages WHERE status='Available'", con)
cmd.CommandType = CommandType.Text
cmd.CommandTimeout = 420
dtstages.Load(cmd.ExecuteReader)
If dtstages.Rows.Count <> 0 Then
cbox_stage.DataSource = dtstages
cbox_stage.DisplayMember = "stage"
cbox_stage_id.DataSource = dtstages
cbox_stage_id.DisplayMember = "ID"
con.Close()
Else
con.Close()
End If
End Using

يمكنكم متابعة الدرس عن طريق اليوتيوب

تعليقات
إرسال تعليق