Solved

New to ADO.NET >> How Do I find a specific row in a dataset, and then display it's data.

Posted on 2004-09-22
4
241 Views
Last Modified: 2010-04-23
Hi

I would like to know how to do a simple "select in listbox..display appropriate data in textboxes"

I.E.

Select Order Number in listbox, when clicked, update textboxes with specific order details.

I can get the data into a dataset, then inot a listbox.....but i really don't want to step through all the records and check when the value is whatever is selected in the listbox...

I tried playing around with the dataview's rowfilter...but I'm not getting anywhere...

Cheers and Thanx

Fade
0
Comment
Question by:x50Fade
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
natloz earned 250 total points
ID: 12127059
Map a view onto your dataset containing details....make sure the pkOrderID is in dataset with details because this is what you will match on for you filter...

Public Sub look_for_child()

        Dim drv1 As DataRowView 'Data Row View object to query DataView object

        'Associate the dataview
        Dim dataview1 As New DataView
        dataview1.Table = dsOrders.Tables("tblOrderDetails")

        'Apply a filter against any of the columns in View...
         dataview.RowFilter = "[fkOrderHeaderID] =" & intSelectedListBoxID <---Replace with ID selected in listbox

        For Each drv1 In dataview1
            txtSample1.text = CStr(drv1("LineItem"))
            txtSample2.text = CStr(drv1("Qty"))
            txtSample3.text = CStr(drv1("Description"))
        Next
    End Sub
0
 
LVL 2

Author Comment

by:x50Fade
ID: 12130525
Right..I see

One more thing...Do we have to use the primrary key when using the rowfilter?

I gotta confess...my database design has never really been according to general practices.....So some of my old App's DB's will not have very usefull PK's, and i might need to use that data.

Regards
Fade
0
 
LVL 7

Expert Comment

by:natloz
ID: 12133432
You can filter on any column of you dataset...not just the primary key...so I gather you are going to filter on the Order Number? If it is guaranteed unique you can probably think of it as a primary key I suppose.
0
 
LVL 2

Author Comment

by:x50Fade
ID: 12158028
Oh, OK

The reason why I'm asking is that the documentation says that you must filter on the primrary key.....so I tough that ADO.NET might check if the column you supply actually is a primrary key....
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now