Hey guys I have a new problem. I am using mysql as my database. I want to get the sum of an amount between 2 dates heres my code for mysql:
select sum(amount) from orderline group by orderlinedate between 'Datehere' and 'Datehere';
But my problem is how do i get it so that the "sum(amount) " will be placed in a textbox in vb.net 2010.
Here is my current code. This code is in a button and whats supposed to happen is that when i click on the button the sum will go to the textbox
but nothings happening.
Private Sub cmdCal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCal.Click
If connection.State = ConnectionState.Closed Then
connection.Open()
End If
Dim sqlstatement As MySqlCommand = New MySqlCommand
sqlstatement.Connection = connection
Dim sqlreader As MySqlDataReader
Try
sqlstatement.CommandText = "select sum(amount) from orderline group by orderlinedate " & _
"between '" & txt1st.Text & "' and '" & txt2nd.Text & "';"
sqlreader = sqlstatement.ExecuteReader()
While (sqlreader.Read())
txtTotal.Text = (sqlreader("amount"))
End While
sqlstatement.Dispose()
sqlreader.Close()
Catch ex As Exception
End Try
End Sub
So thats my problem guys. Some help would be appreciated