Reputation: 93
Can anyone help me find the error with this MySQL command
It show some error near start_date & "AND" & end_date
Using ValSql As MySqlCommand = New MySqlCommand("SELECT SUM(adult_tickets), SUM(child_tickets), SUM(income) FROM `transaction` WHERE from_st ='" & from_st & "'" & " AND " & "to_st ='" & to_st & " AND " & "date BETWEEN'" & start_date & "AND" & end_date & "'", DBConnection)
Upvotes: 0
Views: 39
Reputation: 2267
You appear to be missing a closing quote in the SQL after the to_st
column here:
"to_st ='" & to_st & " AND "
You need to add a closing single quote before the AND
.
Alternatively, use SQL parameters like Andrew Morton suggested rather than SQL concatenation. It's a much easier and safer approach and avoids issues like this.
Upvotes: 1