Solved

Dataview sort problem

Posted on 2006-07-11
4
655 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
[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
4 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 350 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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