myCommand.CommandText = "SELECT 'USED' FROM `KEYS` WHERE `KEYS`.`KEY` = '" + TextBox1.Text + "'"
Dim myReader As MySqlDataReader
myReader = myCommand.ExecuteReader
While (myReader.Read())
MessageBox.Show(myReader.GetString(0))
End While
The returning string is "USED". But that is wrong: it should be returning integer 0 instead. Why is that?
Edit: I changed the MessageBox line to MessageBox.Show(myReader.GetInt16(0)) but now it sends me an error telling me that the input string is not in the right format..
You need backtick, not apostrophe ` not ‘
You’re actually selecting the string “USED” rather than the column. You could just remove the apostrophes all together and say
Also as a note, don’t use dynamic SQL–used prepared queries:
Otherwise you’re very susceptible to SQL injection (which is a very bad thing).