Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sorting a dataset
Message
De
18/07/2013 10:06:20
 
 
À
18/07/2013 08:55:25
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01578641
Message ID:
01578739
Vues:
32
>>If oData is the table (code doesn't show what it is) then in the first instance you are looping thru that (unsorted) and in the second you are (correctly) using the DataView.
>>
>>IAC it might be better to use the DataView constructor to specify the sort order (http://msdn.microsoft.com/en-us/library/8sd1cd0a.aspx) rather than using the defaultview reference -
>>
>>"Creating a DataView without specifying sort or filter criteria and then setting the Sort, RowFilter, or RowStateFilter properties later causes the index to be built at least twice: once when the DataView is created, and again when any of the sort or filter properties are modified." (http://msdn.microsoft.com/en-us/library/hy5b8exc.aspx)
>
>The first example should have been:
>
>
>        Public oDataSet As DataSet = New DataSet
>        Public oRows As DataRowCollection = Nothing
>        Private oDataView As DataView = New DataView
>
>            oDataSet.Tables.Add("Temp")
>
>            oDataSet.Tables(0).Columns.Add("Extension", GetType(System.String))
>            oDataSet.Tables(0).Columns.Add("LastUpdate", GetType(System.DateTime))
>            oDataSet.Tables(0).Columns.Add("Name", GetType(System.String))
>            oDataSet.Tables(0).Columns.Add("Size", GetType(System.Int32))
>            oDataSet.Tables(0).Columns.Add("JustName", GetType(System.String))
>            oDataSet.Tables(0).Columns.Add("CreationTime", GetType(System.DateTime))
>
>            ' Create the view
>            oDataView = oDataSet.Tables(0).DefaultView
>
>            ' Sort the dataset into the primary key
>            oDataView.Sort = "Name"
>
>            ' Make oRows available
>            oRows = oDataSet.Tables("Temp").Rows()
>
>            ' For each record
>            For lnCounter = 0 To nCount - 1
>                loRow = oRows(lnCounter)
>
>            Next
>
I was referring to the code in the second (SQL) example (comparing working to non-working versions)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform