The online racing simulator
mysql parameters
(4 posts, started )
mysql parameters
Hi,

I'm trying to work with parameters in my mysqlqueryies... but I guess I'm doing something wrong cause I don't get any output..

works fine:
string strQryGetPlayerConn = "SELECT * " +
"FROM ws_insim_users " +
"WHERE username = '" + playerConn.Username + "';";

MySqlCommand qryGetPlayerConn = mysqlConn.CreateCommand();
qryGetPlayerConn.CommandText = strQryGetPlayerConn;

MySqlDataReader reader = qryGetPlayerConn.ExecuteReader();

doesn't work:
string strQryGetPlayerConn = "SELECT * " +
"FROM ws_insim_users " +
"WHERE username = @UserName;";
MySqlCommand qryGetPlayerConn = mysqlConn.CreateCommand();

qryGetPlayerConn.CommandText = strQryGetPlayerConn;

qryGetPlayerConn.Parameters.Add("@UserName", MySqlDbType.String);
qryGetPlayerConn.Parameters["@UserName"].Value = playerConn.Username;

MySqlDataReader reader = qryGetPlayerConn.ExecuteReader();

I have no clue what I did wrong... Or perhaps those parameters only work with I, U, D ?
Im nowhere near a MySQL player, but try setting the value of the parameter before passing it to the query.
Quote from BurnOut69 :Im nowhere near a MySQL player, but try setting the value of the parameter before passing it to the query.

You mean moving commandtext= .. under Parameters?

didn't worked..
I meant changing the order of these lines so they end up like this:


qryGetPlayerConn.Parameters["@UserName"].Value = playerConn.Username;
qryGetPlayerConn.Parameters.Add("@UserName", MySqlDbType.String);

mysql parameters
(4 posts, started )
FGED GREDG RDFGDR GSFDG