I have a registration form i would like to submit to a SQL 2008 database, I thought I had it right, but it doesn’t seem to be working. i posted the code belowe to show what i have so far.
Basically I would like to know if the code i have should work, if not could someone show me how to tweek what i have.
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlConnection NutRegistration = new SqlConnection("Data Source=server; Initial Catalog=DBname;Integrated Security=false;User ID=uname;Password=password");
NutRegistration.Open();
SqlCommand thisCommand = NutRegistration.CreateCommand();
thisCommand.CommandText = "INSERT INTO users (txtNickName, txtEmail, txtPassword) VALUES (nickname, email, password);";
NutRegistration.Close();
}
thanks in advance
You are not executing the Command, you are just setting the CommandText.
This should work:
Do it after setting CommandText and before closing the connection.
This will also return the number of affected rows.