Tampilkan List ComboBox Dari Records Database
Harap perhatikan koneksi pada database di tiap PC anda.
langsung copas biar seperti di bawah ini .
Langsung copas :
Public Sub caricombo()
Dim conn As New SqlConnection
Dim cmd As SqlCommand
Dim rdr As SqlDataReader
conn = New SqlConnection(dinas_penduduukan_pencatatan_sipil.My.Settings.db1ConnectionString)
Try
conn.Open()
cmd = New SqlCommand("SELECT id_penduduk FROM penduduk", conn)
rdr = cmd.ExecuteReader()
While rdr.Read()
TextBox7.Items.Add(rdr("id_penduduk"))
End While
Catch ex As Exception
MessageBox.Show("Koneksi Gagal !!!, karena " & ex.Message)
End Try
'ComboBox1.SelectedIndex = 0
End Sub
Lalu panggil fungsi caricombo di form load.
Sekian dan terima kasih
0 comments:
Post a Comment