1
I have a small problem in the Access query , where I have the following code :
Dim cn As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim Da As New OleDb.OleDbDataAdapter
Dim Dt As New DataTable
Dim dtinicio As String
Dim dtfim As String
Dim NO As String
dtinicio = txtDt1.Text
dtfim = txtDt2.Text()
NO = TextBox1.Text
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Firebird.mdb"
cn.Open()
txtDt1.Text = CDate(txtDt1.Text).ToString("dd/MM/yyyy")
txtDt2.Text = CDate(txtDt2.Text).ToString("dd/MM/yyyy")
Try
With cmd
.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@dtInicio", dtinicio)
cmd.Parameters.AddWithValue("@dtFim", dtfim)
.CommandText = "SELECT dt , SUM(UNI) AS UNI FROM RELATORI WHERE dt between @dtInicio and @dtFim ORDER BY dt ORDER BY dt"
.Connection = cn
End With
With Da
.SelectCommand = cmd
Dt = New DataTable
.Fill(Dt)
RELATORIDataGridView.DataSource = Dt
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
cmd.Parameters.Clear()
cmd.Parameters.Clear()
what I need , would include in the line :
.CommandText = "SELECT dt , SUM(UNI) AS UNI FROM RELATORI WHERE dt between @dtInicio and @dtFim ORDER BY dt ORDER BY dt"
a few more fields with the SUM, in case more 3 . I could not find a way to insert the other fields that in the case would be "SALE", "GROUP", "COUPON". Someone would have an example of how I do it ?
You want to add up the sales quantities, groups and coupons or you want them to appear in the grouping?
– Leonel Sanches da Silva
I have the group of cakes coffee and soft drinks , I want to group the cakes sold within the cake group and etc. add the units I sold, and the value I had to the total with each group.
– Vynicius Henrique