|
-
May 30th, 2011, 09:52 AM
#1
Thread Starter
Member
sum column based on date on Datagridview
Hy, I need a help on this, I have a datagridview with several columns, but what I´m trying to do is sum km2 column based on date. I´m using the following code:
Code:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CadastroSeqTableAdapter.Fill(Me.Db01DataSet.CadastroSeq)
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db01.mdb")
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
sql = "SELECT Data, Sum(Km2_FF) FROM CadastroSeq GROUP BY Data"
da = New OleDbDataAdapter(sql, con)
Dim dt As New DataTable("CadastroSeq")
da.Fill(dt)
CadastroSeqDataGridView.DataSource = dt
End Sub
The query is grouping by DATE (data), this OK, but the km2_FF values not, is not showing anything. Do you guys have a different solution or to fix this one?
To be more clearer, this datagridview has different values of km2_FF for the same date, I want to display the total of km2_FF for each day.
Thanks.
-
May 30th, 2011, 07:08 PM
#2
Re: sum column based on date on Datagridview
That SQL is going to group records where Data is the same. If records aren't grouped then that would suggest that Data is not the same. Is it maybe that the dates are the same but they all have different times?
-
May 31st, 2011, 08:36 AM
#3
Thread Starter
Member
Re: sum column based on date on Datagridview
The SQL is grouping the date records, but the km2 is not summing. All the Dates have the same time (00:00:00).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|