从 SystemDateTime 设置 CrmDateTime

问题描述 投票:0回答:3

我有一个与 MSCRM 4.0 交互的应用程序。当我尝试时 更新出生日期字段 联系 我每次都会收到一条错误消息 时间。每个错误都不同 是时候我尝试一种新方法了...

所以 问题是在 以下代码如何更新 我即将认识的新联系人的生日 来创造?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProjectName.CrmSdk;

//The CrmSdk ref is to the webservice url.

//ServerName and OrgName are setup in code but not included.
//standard CRM service setup
CrmSdk.CrmAuthenticationToken token = new CrmSdk.CrmAuthenticationToken();
token.AuthenticationType = 0; //AD on premise
token.OrganizationName = orgName.ToString();

CrmService service = new CrmService();
service.Url = "http://" + serverName.ToString() + "/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

DateTime dt = new DateTime();

// set the date time to some date...
contact c = new contact();

c.firstname = "joe";
c.lastname = "Smack";
c.BirthDay = dt.ToString();
c# dynamics-crm dynamics-crm-4
3个回答
4
投票

CrmDateTime 变量名称 = CrmTypes.CreateCrmDateTimeFromUser(DateTime.Now)


0
投票

您需要使用 CRMDateTime 对象 - Technet 上有关 CRMDateTime 类的文档:

http://technet.microsoft.com/en-us/library/aa613542.aspx

此代码片段也可能有帮助作为示例:

http://mahenderpal.wordpress.com/2010/04/15/set-crm-datetime/


0
投票

日期格式非常挑剔,使用固定格式转换它,也许还包括你想要的时区...

参考。 : 链接

© www.soinside.com 2019 - 2024. All rights reserved.