S
SyntaxTerra
Guest
Hi all, I'm trying to run an SQL query through my vb.net application but there is a syntax error in my query that has got me stumped... here's the code:
Dim answer As String = comboBoxSpecies.Text
Dim query As String = "SELECT SUM(stayCost) FROM stay WHERE petID in (SELECT petID from pet where species=)" & answer
Dim totalCost As Double = da.Getstay(query)
lblTotalAmountPaidOutput.Text = totalCost
As you can see im attempting to attach a string variable to my sql query, the variable is define from a combo box selection, but when i run it i get the following error:
'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')dog' at line 1'
(the variable "answer" contains the string 'dog')
Ive tried moving the commas and parenthesis all over the place with no luck
If anyone can see the error in my syntax and let me know it would be much appreciated, thanks.
Continue reading...
Dim answer As String = comboBoxSpecies.Text
Dim query As String = "SELECT SUM(stayCost) FROM stay WHERE petID in (SELECT petID from pet where species=)" & answer
Dim totalCost As Double = da.Getstay(query)
lblTotalAmountPaidOutput.Text = totalCost
As you can see im attempting to attach a string variable to my sql query, the variable is define from a combo box selection, but when i run it i get the following error:
'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')dog' at line 1'
(the variable "answer" contains the string 'dog')
Ive tried moving the commas and parenthesis all over the place with no luck
If anyone can see the error in my syntax and let me know it would be much appreciated, thanks.
Continue reading...