Figure 1.0 |
Step 2 >>>> select the ComboBox and go to its Property. (fig 1.1)
Figure 1.1 |
into its property, change its DropDownStyle to DropDownList.
Step 3 >>>> press F7 or go into you code and lets start coding.
on top of your code, paste the code below,
Imports MySql.Data
Imports MySql.Data.MySqlClient
this code use to connect into your MySql database.
inside your Private Sub Form1_Load, paste this code;
SQLcon() //connection to your database
ComboBox
str = "select * from info order by Dept" // query use to select data from your table
con.Open()
cmd = New MySqlCommand(str, con)
dr = cmd.ExecuteReader()
While dr.Read
ComboBox1.Items.Add(dr.Item("Dept"))
End While
con.Close()
try to run now your form if you successfully connect your ComboBox into your Database.
0 komentar:
Posting Komentar