Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 28th, 2012, 09:04 PM
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:
 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


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

    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

        Dim da As OleDbDataAdapter = New OleDbDataAdapter
        Dim ds As DataSet = New DataSet
        da.SelectCommand = cmd

        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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a text box from a combo box value dnf999 Access VBA 7 February 6th, 2012 02:24 PM
Populate a list box from comma separated values CoderNH Access VBA 3 October 20th, 2008 08:37 AM
Populate a List Box with Table Names & Table date hewstone999 Access VBA 1 February 27th, 2008 10:10 AM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM

All times are GMT -4. The time now is 06:30 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.