I am trying to make a form send info to a database. The code for my button is below. It seems to connect to the database, but all the values that are added are null. Am I missing something? I've rechecked the ids for the fields in the form (TextBoxUN,TextBoxEmail..) and they all match.
Thanks.
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["apstestConnectionString"].ConnectionString);//string used in sql datasource
conn.Open();
string insertQuery = "insert into asptable (username,email,password,country) values (@Uname,@email,@password,@country)";
MySqlCommand com = new MySqlCommand(insertQuery, conn);
com.Parameters.AddWithValue("@Uname,", TextBoxUN.Text);
com.Parameters.AddWithValue("@email,", TextBoxEmail.Text);
com.Parameters.AddWithValue("@password,",TextBoxPass.Text);
com.Parameters.AddWithValue("@country,",DropDownListCountry.SelectedItem.ToString());
com.ExecuteNonQuery();
conn.Close();
Response.Redirect("Manager.aspx");
}
catch(Exception ex){
Response.Write("Error:"+ex.ToString());
}
}