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
243 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 our DevOps Team Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Variable Event ? 3 30
VB 2005 Tooltips on Form Load Event 15 31
SQL LINE CONTINUATION ISSUE 12 34
i have to take the screenshot of command prompt? how to do this? 1 38
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…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

825 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