コード例 #1
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=DESKTOP-KT69I3S;Initial Catalog=WCFService;Persist Security Info=True;User ID=sa;Password=ifan99");

            con.Open();
            SqlCommand cmd = new SqlCommand("Update UserTable 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);
        }
コード例 #2
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=LAPTOP-HGH9CCBA;Initial Catalog=MyTestDB;Persist Security Info=True;User ID=sa;Password=311000;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);
        }
コード例 #3
0
        public string Update(UpdateUser u)
        {
            string messege;

            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)
            {
                messege = "Successfully Updated";
            }
            else
            {
                messege = "Failed to Updated";
            }
            return(messege);
        }
コード例 #4
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=TEPOS;Initial Catalog=TestDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=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 = "Berhasil Update Data";
            }
            else
            {
                Message = "Gagal Update Data";
            }
            return(Message);
        }
コード例 #5
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=DESKTOP-0QLRLVG;Initial Catalog=CrudDB;Persist Security Info=True;User ID=sa; Password=albana123");

            con.Open();
            SqlCommand cmd = new SqlCommand("Update dbo.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 = "Successfuly Updated";
            }
            else
            {
                Message = "Failed to Update";
            }
            return(Message);
        }
コード例 #6
0
        public string Update(UpdateUser u)
        {
            string        Message = "";
            SqlConnection con     = new SqlConnection("Data Source=DESKTOP-CM1O7BQ;Initial Catalog=MyTestDB;User ID=sa;Password=123");

            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);
        }