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 quote report from C# code

(0) ShareShare
ReportReport
Posted on by

Hi

I want to run a Quote report using C#, I encountered the following code:

            Guid orgid, userid;
            WhoAmIResponse(out orgid, out userid);

            ReportViewer rViewer = new ReportViewer();
            rViewer.ServerReport.ReportServerCredentials.NetworkCredentials = new NetworkCredential("000000",
                "000000", "000000000");
            rViewer.ProcessingMode = ProcessingMode.Remote;
            rViewer.ShowPrintButton = true;
            rViewer.ServerReport.ReportServerUrl = new Uri(url);
            rViewer.ServerReport.ReportPath = path;

            //CRM Report 
            DataSourceCredentials dsc = new DataSourceCredentials();
            dsc.UserId = userid.ToString();
            dsc.Password = orgid.ToString();
            dsc.Name = "CRM"; //"MSCRM_DataSource"; //
            List<DataSourceCredentials> dscs = new List<DataSourceCredentials>();
            dscs.Add(dsc);
            rViewer.ServerReport.SetDataSourceCredentials(dscs);


But it throws an error, that When I check the Reporting service error log files, it is as below :

System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object 'p_GetCrmUserId', database 'MSCRM_CONFIG', schema 'dbo'. ---> Microsoft.Crm.Reporting.DataExtensionShim.Common.ReportExecutionException: The EXECUTE permission was denied on the object 'p_GetCrmUserId', database 'MSCRM_CONFIG', schema 'dbo'.


But, When I execute the sp in SQL server studio, it runs and returns the CRMUSER Id.

My Reporting service configuration is : 

Report Server Service Account Set to "Network Service"

Current Report Server Database Credentials Set To NT Authority\NetworkService

Would you help me please ? 

Regards

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nuno Profile Picture
    2,005 on at

    Hi,

    On SQL Studio, go to 'MSCRM_CONFIG' and check if the account 'Network Service' has execute permission on stored procedure 'p_GetCrmUserId'.

  • Community Member Profile Picture
    on at

    Thanks. I gave admin access to Network service and now get the following error:

    The SELECT permission was denied on the object 'ConfigSettings', database 'MSCRM_CONFIG'

    I gave "Select" grant to both CRM user and Networkservice and still get the above error. 

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