using access with combo box

Steven Low

Active member
Joined
Apr 14, 2005
Messages
42
Programming Experience
1-3
Hi Guys

I like to to use a combo box which reads off access the first colum student ID from the student table.

and display the results in the selected text box.


Heres what i have done with no luck. within the combo box.


VB.NET:
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\proj.mdb;") 


        cn.Open() 
        cmd = New OleDbCommand(String.Format("select * from student where StudentID = '{0}'", Me.cb1.SelectedItem), cn) 

        dr = cmd.ExecuteReader 
        While dr.Read() 
            tx0.Text = dr(0) 
            tx1.Text = dr(1) 
            tx2.Text = dr(2) 
            tx3.Text = dr(3) 
            tx4.Text = dr(4) 
            tx5.Text = dr(5) 
            'tx6.Text = dr(6) 
            tx7.Text = dr(6) 

        End While 
        dr.Close() 
        cn.Close() 
    End Sub
 
Back
Top