web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Calling stored procedure in CRM Plugin

(0) ShareShare
ReportReport
Posted on by

I am trying to access a stored procedure in CRM database by creating a linq to sql data class in CRM Plugin.

I keep getting below error.

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.Detail

Please help.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi Montek,

    Check this post..

    blogs.msdn.com/.../accessing-a-sql-database-from-a-microsoft-dynamics-crm-plug-in.aspx

    This post showing how to access database from CRM plugin.

    Also check

    community.dynamics.com/.../154936

    Best option to call database from plugin is create webservice and in web service call database.. and call this web service into plugin.. then you will not get this kid of error.

    as you are not directly accessing database from plugin.

    Hope this will help..

  • Suggested answer
    Mamatha Swamy Profile Picture
    5,426 on at
  • Suggested answer
    Abed Haniyah Profile Picture
    4,287 on at

    Dear Montek,

    Please note that accessing CRM database directly from plugin is not supported, you can use web service.

    Regards,

    Abed.

  • Aileen Gusni Profile Picture
    44,524 on at

    Montek,

    Creating Store Proc in the CRM Database is unsupported.

    If you want to call store procedure outside CRM DB then it's fine.

    It seems your user doesn't have permission to access the SQL Object.

  • Community Member Profile Picture
    on at

    You can also get around this error by registering the plugin outside of the sandbox - in the plugin assembly, within the CRMPackage there should be a registerfile.crmregister - if you change the IsolationMode="Sandbox" to IsolationMode="None" then this fixed the problem for me. However this depends whether or not sandbox registration is essential for your plugin or not

  • Suggested answer
    Hamzeh Zawahreh Profile Picture
    3,674 on at

    hi Montek

    you can the code in this link:

    http://blogs.msdn.com/b/crm/archive/2008/07/08/accessing-a-sql-database-from-a-microsoft-dynamics-crm-plug-in.aspx 

    but you have to put your stored procedure instead of the command text

    goo luck.

  • Suggested answer
    Hamzeh Zawahreh Profile Picture
    3,674 on at

    hello,

    back again

    you can create a web service. It can be a WCF service or classic ASMX service.

    then put your code in it(calling SP in you custom code) then deploy it.

    then you can create a button in the CRM form and call the service using JavaScript. You should be able to configure your service so that it can be invoked by passing any arguments in the URL parameters.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans