The following code is written in vb.net 2008
Expand|Select|Wrap|Line Numbers
- Public Class Form1
- Sub fillcombo()
- strsql = "select * from device"
- Dim cmd As New OleDb.OleDbCommand
- cmd.CommandText = strsql
- cmd.Connection = con
- dr = cmd.ExecuteReader
- While (dr.Read())
- ComboBox1.Items.Add(dr("device"))
- End While
- cmd.Dispose()
- dr.Close()
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Module1.connect()
- Me.fillcombo()
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- strsql = "select part from part where device='" & ComboBox1.Text & "'"
- Dim cmd As New OleDb.OleDbCommand
- cmd.CommandText = strsql
- cmd.Connection = con
- dr = cmd.ExecuteReader
- If (dr.Read() = True) Then
- ComboBox2.Text = (dr("part"))
- End If
- cmd.Dispose()
- dr.Close()
- End Sub
- End Class
In MS access 2007 i hav created 2 tables:
1)contains the device ex:computer
2)contains the device and its parts ex:cpu,monitor so here the device has duplicate values
table names are device and parts
guys help!!!!!