Ejemplo n.º 1
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=DESKTOP-M66THJ5;Initial Catalog=MyTestDB;Persist Security Info=True;User ID=sa;Password=12345;Pooling=False");

            con.Open();
            SqlCommand cmd = new SqlCommand("Update UserTab set Name = @Name, Email = @Email where UserID= @UserID ", con);

            cmd.Parameters.AddWithValue("@UserId", u.UID);
            cmd.Parameters.AddWithValue("@Name", u.Name);
            cmd.Parameters.AddWithValue("@Email", u.Email);
            int res = cmd.ExecuteNonQuery();

            if (res == 1)
            {
                Message = "Successfully Updated";
            }
            else
            {
                Message = "Failed to Update";
            }
            return(Message);
        }
Ejemplo n.º 2
0
        public string Update(UpdateUser u)
        {
            string Message = "";

            SqlConnection con = new SqlConnection("Data Source=LAPTOP-E77BQ7S0;Initial Catalog=WcfService2;User ID=sa;Password=123;Pooling=False");

            con.Open();
            SqlCommand cmd = new SqlCommand("Update UserTab set Name = @Name, Email = @Email where UserID = @UserID", con);

            cmd.Parameters.AddWithValue("@UserID", u.UID);
            cmd.Parameters.AddWithValue("@Name", u.Name);
            cmd.Parameters.AddWithValue("@Email", u.Email);
            int res = cmd.ExecuteNonQuery();

            if (res == 1)
            {
                Message = "Successfully Updated";
            }
            else
            {
                Message = "Failed to Update";
            }
            return(Message);
        }