This is my code I think I am doing right so far but I really dunno what is the problem. I am making a register form with txtbox for username and password I encrypt the password with MD5, I tried deleting the MD5 encryption thinking that it might be the prtoblem but still when I deleted it the problem is still occur.
ApareceCrudLib a = new ApareceCrudLib("localhost", "root", "", "cashieringdb");
string query = "INSERT INTO register (username,password) " +
"VALUES(" +
"'" + txtUser.Text + "'," +
"MD5('" + txtPass.Text +"')";
a.mysqlInsert(query);
MessageBox.Show("Account has been registered!");
this.Close();
This is the code for my class ApareceCrudLib for mysqlInsert
public void mysqlInsert(string query)
{
try
{
if (this.Open())
{
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.ExecuteNonQuery();
this.Close();
System.Windows.Forms.MessageBox.Show("Record Inserted!");
}
}
catch { this.Close(); System.Windows.Forms.MessageBox.Show("INSERT Record Error!"); }
return;
}
as you can see I catch the error with dialog box so basically if it will fail to insert or connect to database the message box shows "INSERT Record Error!". By the way there is no error in visual studio only in inserting to database.
I think the error somewhere in the code for inserting database string query = "INSERT
INTO register (username,password) " +
"VALUES(" +
"'" + txtUser.Text + "'," +
"MD5('" + txtPass.Text +"')";
maybe a comma a semi-colon a period I am clueless.
Hi!rhughes here is the image of the error!
