?
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
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
natloz earned 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 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