public void updateUserStatus(User user) { string sqlCommandString = @"UPDATE Users SET isActive = @userIsActive WHERE userID=@userID"; command = new SqlCommand(sqlCommandString, myConnection); p_ID = command.Parameters.Add("@userID", SqlDbType.Int); p_isActive = command.Parameters.Add("@userIsActive", SqlDbType.Int); p_ID.Value = user.mail.GetHashCode(); p_isActive.Value = user.GetIsActive(); command.ExecuteReader(); }
public void insertUser(User user) { //string sqlCommandString = INSERT_INTO + userTableName + " " + VALUES + "(" +"'"+ user.name + COMMA + user.password + COMMA + user.mail + COMMA_NEXTINT + user.mail.GetHashCode() + COMMA_NEXTINT + user.GetIsActive() + ")"; string sqlCommandString = @"INSERT INTO Users (Username, Password, Email, userID, isActive) VALUES (@userName, @userPassword, @userMail, @userID, @userIsActive)"; command = new SqlCommand(sqlCommandString, myConnection); p_userName = command.Parameters.Add("@userName", SqlDbType.Text); p_password = command.Parameters.Add("@userPassword", SqlDbType.Text); p_Email = command.Parameters.Add("@userMail", SqlDbType.Text); p_ID = command.Parameters.Add("@userID", SqlDbType.Int); p_isActive = command.Parameters.Add("@userIsActive", SqlDbType.Int); p_userName.Value = user.name; p_password.Value = user.password; p_Email.Value = user.mail; p_ID.Value = user.mail.GetHashCode(); p_isActive.Value = user.GetIsActive(); command.ExecuteReader(); }