I have a hard time figuring out what is wrong about my code. The purpose is to take data from a registering form in ASP to my user data columns in my SQL database.
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
try
{
string cmd = "insert into UserLogin
values(@UserName,@Password)";
SqlConnection cnn = new SqlConnection(cmd);
SqlCommand cmd2 = new SqlCommand(cmd, cnn);
cmd2.Parameters.AddWithValue("@UserName", UsernameBox.Text);
cmd2.Parameters.AddWithValue("@Password", PasswordBox.Text);
cnn.Open();
cmd2.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand(cmd, connection);what is wrong about my code- What is wrong? Do you get any error?