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?