VB.NET: Populating ComboBox Using MySQL Query -
i trying populate combobox mysql database; don't anything. below code.
table: class
columns: code, state
sqlstr = "select * class state= not started" dbcmd = new mysql.data.mysqlclient.mysqlcommand(sqlstr, dbconn) dbdr = dbcmd.executereader while (dbdr.read()) cb_class.items.add(dbdr("code")) end while dbcmd.dispose() dbdr.close()
i believe result wrong, because there @ least 2 records state values set "not started". wrong? there wrong way i've written "state= not started" ?
the command text doesn't seems correct. lacks single quote around string search
sqlstr = "select * class state='not started'" ^ ^
if state
string field every search on should enclosed in single quotes.
beware of potential problems when string search contains single quote.
in simple case use directly string constant, if render search dynamic user input should use parametrized queries.
Comments
Post a Comment