Click here to Skip to main content
15,904,415 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is my code
Dim connection As OleDbConnection
       Dim adapter As OleDbDataAdapter
       Dim ds As New DataSet
       Dim SQLStr As String
       Dim cmd As OleDbCommand
       connection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=consignacion.mdb;")
       SQLStr = "SELECT sum(total) FROM salesdb WHERE buydate=@buydate GROUP BY buyer"
       cmd = New OleDbCommand(SQLStr, connection)
       cmd.Parameters.AddWithValue("@buydate", Form1.Lbldate2.Text)

       Try
           connection.Open()
           adapter = New OleDbDataAdapter(cmd)
           adapter.Fill(ds)
           connection.Close()
           DataGridView1.DataSource = ds.Tables(0)
       Catch ex As Exception
           MsgBox(ex.ToString)
       End Try


What I have tried:

Quote:
>data<
Buyer total
GIAN 100.00
BANAL 5,000.00
BANAL 2,200.00
JUN CASH 12,321.00

>output<

buyer total newcolumnautoadded
100.00
7,200.00
12,321.00

wanted output
GIAN 100.00
BANAL 7,200.00
JUN CASH< 12,321.00


just made it work via searching and learning please help me here.
i want to display the names too.
Posted
Updated 3-Feb-19 20:49pm

1 solution

Sorry. i got the answer hehe.

Quote:
SQLStr = "SELECT buyer,sum(total) FROM salesdb WHERE buydate=@buydate GROUP BY buyer"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900