Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6388691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:18:37+00:00 2026-05-25T03:18:37+00:00

How do you update records in CRM 2011 using OrganizationServiceContext? Can anyone provide a

  • 0

How do you update records in CRM 2011 using OrganizationServiceContext? Can anyone provide a simple example? Thanks!

This is my code:

using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Linq;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Client.Services;
using System.Data.Services;
using System.Text.RegularExpressions;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Web.Security;
using System.Data;
using System.Collections.Specialized;
using System.Web.SessionState;
using System;
using System.Web.Profile;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web.UI.WebControls.WebParts;
using System.Web;
using System.Web.UI;
using System.Drawing;
using System.Text;
using System.Web.Caching;
using Telerik.Web.UI;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Data.Entity;
using System.Data.Entity;

public partial class LeadShareEditPanel : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{


}
protected void imgBtnSaveNote_Click(object sender, ImageClickEventArgs e)
{
    Uri organizationUri = new Uri("http://server/CRMT/XRMServices/2011/Organization.svc");
    Uri homeRealmUri = null;
    ClientCredentials credentials = new ClientCredentials();
    credentials.Windows.ClientCredential = new System.Net.NetworkCredential("user", "password", "domain");
    OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
    // Get the IOrganizationService

    //Get OrganizationServiceContext -the organization service context class implements the IQueryable interface and
    //a .NET Language-Integrated Query (LINQ) query provider so we can write LINQ queries against Microsoft Dynamics CRM data.

    using (var service = new OrganizationService(orgProxy))
    using (var context = new CrmOrganizationServiceContext(service))
    {
        var contact = context.CreateQuery<Contact>().First(c => c.FirstName == "Bob");
        contact.JobTitle = "Developer";
        context.UpdateObject(contact);
        context.SaveChanges();
        contact.EMailAddress1 = "bob@contoso.com";
        context.UpdateObject(contact);
        context.SaveChanges();
    }


}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:18:37+00:00Added an answer on May 25, 2026 at 3:18 am

    This is an example from the 5.05 SDK help file

    using (var service = new OrganizationService(connection))
    using (var context = new CrmOrganizationServiceContext(service))
    {
    var contact = context.CreateQuery<Contact>().First(c => c.FirstName == "Bob");
    contact.JobTitle = "Developer";
    context.UpdateObject(contact);
    context.SaveChanges();
    contact.EMailAddress1 = "bob@contoso.com";
    context.UpdateObject(contact);
    context.SaveChanges();
    }
    

    If you haven’t already you can download the SDK from here crm 2011 sdk . I would highly reccomend it as it has lots of great samples. The current version is 5.06.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C# and the Salesforce API, I can successfully update records, and I can
I am using the following lines of code to update records based on rowid:
How can i update multiple records in a single statement like this with SQL?:
Can someone please post a confirmed example using linq to retrieve and update a
i am using devexpress grid with edit functioality to update the records in the
We currently have some php code that allows an end user to update records
i've stored procedure, that check against MySql server if can insert or update records.
I am looking to insert and update records in a database using functions and
I am trying to update all records in a column so that they start
I'd like to update all records with an empty string in all columns of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.