View Single Post
  #1 (permalink)  
Old June 28th, 2012, 09:04 PM
03224 03224 is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default List Box to populate DataGridView

I have this windows form, just LISTBOX and DATAGRIDVIEW
i want to dispaly information about an item select in the listbox
i can populate the listbox just fine, but nothig is display on the datagridview when i click on a name
here is my code:
Code:
 Private Sub Status_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'TODO: This line of code loads data into the 'ReturnEquipmentDataSet.RMA' table. You can move, or remove it, as needed.

        Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database\ReturnEquipment.accdb;Persist Security Info=False;")

        Dim CMD1 As New OleDb.OleDbCommand
        CMD1.Connection = con

        con.Open()

        CMD1.CommandText = "SELECT SN from RMA"
        Dim miDataReader As OleDb.OleDbDataReader
        miDataReader = CMD1.ExecuteReader
        Dim dt As New DataTable
        dt.Load(miDataReader)
        LbxSerial.DataSource = dt
        LbxSerial.ValueMember = dt.Columns(0).ToString()
        LbxSerial.DisplayMember = dt.Columns(0).ToString()
        miDataReader.Close()
        con.Close()

    End Sub



    Private Sub LbxSerial_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles LbxSerial.SelectedIndexChanged
        Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database\ReturnEquipment.accdb;Persist Security Info=False;")
        Dim cmd As New OleDbCommand("Select * from( rma) where sn = @SN Order by Rma_Number")
        cmd.Parameters.AddWithValue("@SN", Me.LbxSerial.SelectedItem.ToString)
        cmd.Connection = con

        con.Open()
        Dim da As OleDbDataAdapter = New OleDbDataAdapter
        Dim ds As DataSet = New DataSet
        da.SelectCommand = cmd
        da.Fill(ds)

        DataGridView1.DataSource = ds


    End Sub
End Class
When i run this application no error , but no info is dispaly
what am I doing wrong?
Reply With Quote