Whenever I have
Dim catID as integer
And I use this in a query like this:
cmd.CommandText = \"select * from categories where p
Try
cmd.CommandText = string.Format("select * from categories where parentid='{0}'", catID)
if parentid
is a numeric field in your database then you'll need
cmd.CommandText = string.Format("select * from categories where parentid={0}", catID)
Just remove single quotes:
cmd.CommandText = "select * from categories where parentid=" + catID.ToString()
The error was telling you that it couldn't add "SELECT *..." with your catID value. The '+' operator tried to convert "SELECT *..." into a number so it could do math on it, but it couldn't, so it threw the error.
A lot of people try to use '+' for string concatenation. This is not the best practice because '+' will only concatenate when both sides are strings. But if it finds a number on one side (as in your case, with catID), then it will try to do math instead of concat.
Best practice to just make a habit to never use '+' to concat strings; always use '&' instead. That way you don't have to think about it.
I.e.:
1+1 = 2
1+A = error
1&1 = 11
1&A = 1A