Create ,Delete ,Update Record from Web App to Microsoft Dynamics CRM 2011

Create This Class file>>>..

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Description;
using System.Web;

/// <summary>
/// Summary description for clsXrmConnection
/// </summary>
public class clsXrmConnection
{
   public static IOrganizationService _svc=null;

        public static void establishConn()
        {
            ClientCredentials cred = new ClientCredentials();

            cred.Windows.ClientCredential = new System.Net.NetworkCredential(clsDefaults.username, clsDefaults.password, clsDefaults.domain);
            Uri orgUri = new Uri(clsDefaults.serverUrl + "/" + clsDefaults.orgname + "/XRMServices/2011/Organization.svc");

            OrganizationServiceProxy orgService = new OrganizationServiceProxy(orgUri, null, cred, null);
            _svc = (IOrganizationService)orgService;
        }

        public static IOrganizationService _service(){
            if (_svc == null)
                establishConn();
            return _svc;
        }

}



----------------------------------------------------


sing Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;

do hghere code here.....
like

sssss["fgdg"]=txtx.text;
-----

    try
        {
              Guid newApp = clsXrmConnection._service().Create(ent);
                ent.Id = newApp;
                //Response.Redirect("Index.aspx");
                //Response.Redirect("Index.aspx?CR=" + lblCR.Text);
                Response.Redirect("~/bank/appfileUpload.aspx?appid=" + Request["appid"] + "&CR=" + lblCR.Text + "&id=" + ent.Id);
        }
        catch (Exception)
        {
         
            throw;
        }

Comments