Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie - group looping process
Message
De
11/09/2006 09:45:17
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
10/09/2006 12:21:42
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Jet/Access Engine
Divers
Thread ID:
01152652
Message ID:
01152742
Vues:
21
>Dear All,
>I am very new to VB.NET, I am using VB.NET 2005 and currently I am trying to do stock group looping process ..(see below)
>
>I need advise from the expert .. do I already have correct codes for such stock group looping process below?
>
>
>Try
>    cn.Open()
>    Dim cmd As New OleDbCommand("SELECT * FROM STOCKS ORDER BY STOCKGROUP,STOCKCODE", cn)
>    Dim dr As OleDbDataReader = cmd.ExecuteReader()
>    Dim mStockGroup as  string, mStockCode as string, mStockName as string
>    If dr.HasRows Then
>        Do While dr.Read
>            mStockGroup = dr("StockGroup")
>            Do While dr.Read and dr("StockGroup") = mStockGroup          ' I am not sure for this part !
>                    mStockCode = dr("StockCode")
>                    mStockName = dr("StockName")
>                    messagebox.show(mStockCode & "   " & mStockName)
>            Loop
>       Loop
>End if
>dr.Close()
>Catch ex As OleDb.OleDbException
>MessageBox.show(ex.Message)
>Catch ex As Exception
>MessageBox.show(ex.Message)
>Finally
>cn.Close()
>End Try
>
Winan,

The code is not correct. It will always skip the first row of the result set. If I may make a suggestion, the code will be much cleaner if you use a DataTable and a DataView to perform grouping on the data. Even better yet - if you already know exactly what sort of aggregations or concatenations you will perform based on the grouping, change the SELECT statement to perform the aggregation on SQL Server.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform