Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dataview sort problem

Posted on 2006-07-11
4
Medium Priority
?
671 Views
Last Modified: 2011-04-14
I put the results of a running a stored procedure into a dataset. I then created a dataview to be able to sort:

dim dv as new dataview
with dv
   .table = objDataSet.tables("spResults")
   .sort = "ChargeNumber desc"
end With

I load the table into my datagrid. Works fine. sorted and everything. The problem is, I'm trying to load the results into an excel spreadsheet from the dataview but it won't sort.

for dtRow = 0 to dv.count - 1
   osheet.cells(3, 1).value = dv.table.rows(dtrow).item("Charge")
   .....
and so on

My guess is when I use
   dv.table.rows(dtrow).item("Charge")
it is looking at the first record of the dataview before it was sorted.
How can I change this? I need to go by the sorted order.

Thanks
0
Comment
Question by:MadIce
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 1400 total points
ID: 17086338
Yes, you are getting the data from the table, which is not sorted, rather than from the dataview, which is sorted.  Try this instead

        For Each drv As DataRowView In dv
            osheet.cells(3, 1).value = drv("Charge")
            'and so on
        Next

Roger
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17086450
Roger, how many people get that wrong about the DataView.Table property?  It is not very intuitive, now is it?

Bob
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17086597
No, it's not very intuitive.

I reckon a large part of the problem is DataRow cf DataRowView.  "Data is in DataRows which are in DataTables: DataRowViews are different, and therefore a bit frightening.  I'd better get back to the table."  But the only real difference is that a DataRow can have data in different .RowStates whereas a DataRowView is restricted to one.  And although it is possible to look at (in a DataTable) or choose (for a DataView) other .RowStates than Current, I wonder how many people ever do that for real.

Sermon over.  It's my bedtime ;-)

Roger
0
 

Author Comment

by:MadIce
ID: 17091620
Thanks. Reading your other commit, I was trying to pull from the table rather than the DataRowView. Guess I better read up on DataViews again. Thanks again....
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

927 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