protected void btnSignIn_Click(object sender, EventArgs e) { string strConnection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string strInsert = "INSERT INTO Users (Username,Password) VALUES(@Username,@Password)"; SqlConnection con = new SqlConnection(strConnection); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = strInsert; SqlParameter username = new SqlParameter("@Username", SqlDbType.VarChar, 50); username.Value = txtUserName.Text.Trim().ToString(); cmd.Parameters.Add(username); SqlParameter password = new SqlParameter("@Password", SqlDbType.VarChar, 50); password.Value = txtPassword.Text.Trim().ToString(); cmd.Parameters.Add(password); con.Open(); int result = cmd.ExecuteNonQuery(); con.Close(); }
Saturday, June 09, 2012
CSharp ExecuteNonQuery Sample
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment