hi:
I have a problem filling my combo box from my Access Database values.. Can you please help me with this ?
Thanks,
Kukki.
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Using con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
con.Open()
Dim objcmd As New Data.OleDb.OleDbCommand
Button1.BackColor = System.Drawing.Color.CornflowerBlue
Button2.BackColor = System.Drawing.Color.Bisque
Dim TableName As String = ""
Dim query As String = ""
Dim cbo As ComboBox = Nothing
Dim objrdr As Data.OleDb.OleDbDataReader
For x As Int32 = 1 To 12
Select Case x
Case 1
query = "SELECT DISTINCT Group FROM table1 WHERE Group IS NOT NULL ORDER BY Group"
TableName = "Group"
cbo = ComboBox1
Case 2
query = "SELECT DISTINCT NXVERSION FROM table1 WHERE NXVERSION IS NOT NULL ORDER BY NXVERSION"
TableName = "NXVERSION"
cbo = ComboBox2
Case 3
query = "SELECT DISTINCT ANSYS FROM table1 WHERE ANSYS IS NOT NULL ORDER BY ANSYS"
TableName = "ANSYS"
cbo = ComboBox3
Case 4
query = "SELECT DISTINCT MECH FROM table1"
TableName = "MECH"
cbo = ComboBox4
Case 5
query = "SELECT DISTINCT MACH FROM table1"
TableName = "MACH"
cbo = ComboBox5
Case 6
query = "SELECT DISTINCT UGSTRUCTURES FROM table1"
TableName = "UGSTRUCTURES"
cbo = ComboBox6
Case 7
query = "SELECT DISTINCT MFG FROM table1 WHERE MFG NOT NULL ORDER BY MFG"
TableName = "MFG"
cbo = ComboBox7
Case 8
query = "SELECT DISTINCT MAKE FROM table1 WHERE MAKE NOT NULL ORDER BY MAKE"
TableName = "MAKE"
cbo = ComboBox8
Case 9
query = "SELECT DISTINCT OSPATCHES FROM table1 WHERE OSPATCHES NOT NULL"
TableName = "OSPATCHES"
cbo = ComboBox9
Case 10
query = "SELECT DISTINCT RAM FROM table1 WHERE RAM NOT NULL ORDER BY RAM"
TableName = "RAM"
cbo = ComboBox10
Case 11
query = "SELECT DISTINCT GRAPHICSCARD FROM table1 WHERE GRAPHICSCARD NOT NULL AND ORDER BY GRAPHICSCARD"
TableName = "GRAPHICSCARD"
cbo = ComboBox11
Case 12
query = "SELECT DISTINCT GRAPHICSVERSION FROM table1 WHERE GRAPHICSVERSION NOT NULL AND ORDER BY GRAPHICSVERSION"
TableName = "GRAPHICSVERSION"
cbo = ComboBox12
End Select
objcmd.Connection = con
objcmd.CommandText = query
objrdr = objcmd.ExecuteReader
cbo.Items.Clear()
If objrdr.HasRows Then
Do While objrdr.Read
cbo.Items.Add(objrdr.GetValue(0))
Loop
End If
objrdr.Close()
Next
End Using
End Sub