A: 

I think you need to change the names of the parameters added to the insert command to match the names specified in the INSERT SQL statement.

Try:

insertcommand.Parameters.Add("@username",MySqlDbType.VarChar,50,"username");
insertcommand.Parameters.Add("@password", MySqlDbType.VarChar, 50, "password");
dariom
i have tried that. But no result
Srikanth V M
+1  A: 

I am rather unsure, but doesn't mysql use numbered parameters with a "?"-synatx or named parameters with a ":"-syntax instead of (mssql) at-syntax ?

Something like :

MySqlCommand insertcommand = new MySqlCommand("insert into user(username,password) values(?, ?)", conn);
insertcommand.Parameters.Add(1, MySqlDbType.VarChar,50,"username");
insertcommand.Parameters.Add(2, MySqlDbType.VarChar, 50, "password");

or

MySqlCommand insertcommand = new MySqlCommand("insert into user(username,password) values(:username, :pass)", conn);
insertcommand.Parameters.Add(":username", MySqlDbType.VarChar,50,"username");
insertcommand.Parameters.Add(":pass", MySqlDbType.VarChar, 50, "password");
Nils
hey thanks for the answer. U were absolutely correct. It was just a small syntax error.
Srikanth V M
Have you tried both examples ? Are they both ok ?
Nils
":" generates error. "?" works fine. Second Code snippet wont work.
Srikanth V M
This is somewhat strange: http://dev.mysql.com/doc/refman/5.0/en/connector-net-tutorials-intro.html#connector-net-tutorials-parameters suggests that it is possible to use named parameters which are prefixed with an "@" - much like dariom's anwer displayed.
Nils