This is very simple. Just follow the code.
SqlConnection conn; SqlCommand cmd; string connectionString = ConfigurationManager.ConnectionStrings["MemberConnectionString"].ConnectionString; conn = new SqlConnection(connectionString); conn.Open();userName. cmd = new SqlCommand("INSERT INTO users (uname,Pwd,userRole)VALUES (@userName,@passWord,@role) ", conn); cmd.Parameters.AddWithValue("@userName", userName); cmd.Parameters.AddWithValue("@passWord", passWord); cmd.Parameters.AddWithValue("@role", role); cmd.ExecuteNonQuery(); cmd.Dispose(); conn.Dispose();
Here I have a users table. In this table, I have three fields. They are username, password and user role.
Question and answer is powered by AnsPress.io