Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can anyone help me find the error with this MySQL command

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading