简体   繁体   English

从CRM Dynamics 2011插件连接到SQL

[英]Connect To SQL From CRM Dynamics 2011 Plugin

Hi All I posted a question earlier regarding, how to set an active contract to draft, but doing my research I found out it can either been done going straight into SQL doing the update or do it by copying the contract and then make an update. 大家好,我之前发布了一个有关如何设置有效合同草案的问题,但是我的研究发现,可以直接进入SQL进行更新,也可以通过复制合同然后进行更新来完成。 I had to go for option one. 我必须选择一种。 I'm trying to access my database and update the table, but get a SQL generic error from the plugin. 我正在尝试访问数据库并更新表,但是从插件中获得了SQL通用错误。 My code to access the database from the plugin (I usually use Entity Framework to connect): 我从插件访问数据库的代码(我通常使用Entity Framework进行连接):

string strConn = "Data Source=serverName;Initial Catalog=DatabaseName;IntegratedSecurity=SSPI";

SqlConnection connection = new SqlConnection();
SqlCommand command = new SqlCommand();
connection.ConnectionString = strConn;
connection.Open();
command.Connection = connection;
command.CommandText = "Update ContractBase set StateCode = 0,StatusCode = 1 "
  + "where ContractId = ACC70D43-DEBA-E111-8610-00155D041E80";
command.ExecuteNonQuery();
connection.Close();  

Is there anything else I need to consider when I connect to the database from the plugin? 从插件连接到数据库时,我还有什么需要考虑的吗? Thanks in advance. 提前致谢。

Would the SetStateRequest message not be the appropriate way of setting the state and status? SetStateRequest消息不是设置状态和状态的适当方法吗? or am I missing something? 还是我错过了什么?

I am not sure if this is too late but you can create a SSIS package that stores CRM data in to SQL table. 我不确定是否为时已晚,但是您可以创建一个将CRM数据存储到SQL表的SSIS包。 Create a simple plugin that on create or update fires of this SSIS package. 创建一个简单的插件,该插件可以在创建或更新此SSIS包时触发。

You will have to run this plugin with none isolation mode as the sandbox isolation will not allow file access (package). 您将必须以无隔离模式运行此插件,因为沙箱隔离将不允许文件访问(程序包)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM