?
Solved

Dataview sort problem

Posted on 2006-07-11
4
Medium Priority
?
658 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 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

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

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…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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