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 be to 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"
plus some fields with SUM, in case 3 more. I could not find a way to insert the other fields that in the case would be "SALE", "GROUP", "CUPOM". Would someone have an example of how I do this?