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
245 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

Industry Leaders: 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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