Quantcast
Viewing all articles
Browse latest Browse all 3636

Database connecor error:'' Failed to Retrieve data from the database

Hi,

    Currently I am facing this weird Issue. This issue happens only with few reports and most of them are working fine.

My colleague created two reports. Report 1 and Report 2. Report 2 is a copy of Report 1 with some modifications and both are calling the same storedprocedure. When I call it from Asp.net then Report 1 is working fine but on Report 2, I get Database Connector Error. I have this problem only in .net but in delphi its working fine.

 

For Testing purpose

. In VS2010, When I run the report using 'Main Report Preview' with some parameters and the report works fine.

. I run it in web using same parameters, I get database connector error.

. Both use same login info for MSSQL[2008 R2] database.

. In SQL Profiler, I get error before the StoredProcedure gets called.

 

For database connection I have used

 

  ReportDocument cryRpt = new ReportDocument();

 

 

            //TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();

            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();

            ConnectionInfo crConnectionInfo = new ConnectionInfo();

 

 

            //load report.

            cryRpt.Load(reportPath);

         

            //connection.

            string connStr = WebConfigManager.GetReportConnectionString();

            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connStr);

          

            crtableLogoninfo.ConnectionInfo.AllowCustomConnection = true;

 

 

            crConnectionInfo.ServerName = builder.DataSource;

            crConnectionInfo.DatabaseName = builder.InitialCatalog;

            crConnectionInfo.UserID = builder.UserID;

            crConnectionInfo.Password = builder.Password;

          

            //pass connection to each tables.

            Tables CrTables = cryRpt.Database.Tables;

            foreach (Table CrTable in CrTables)

            {

                crtableLogoninfo.ConnectionInfo = CrTable.LogOnInfo.ConnectionInfo;

                crtableLogoninfo.ConnectionInfo = crConnectionInfo;

                CrTable.ApplyLogOnInfo(crtableLogoninfo);

                CrTable.Location = "dbo." + CrTable.Name;

            }

 

 

            //pass connection to each sub-reports.

            foreach (ReportDocument subRep in cryRpt.Subreports)

            {

                foreach (Table CrTable in subRep.Database.Tables)

                {

                    crtableLogoninfo = CrTable.LogOnInfo;

                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;

                    CrTable.ApplyLogOnInfo(crtableLogoninfo);

                    CrTable.Location = "dbo." + CrTable.Name;

                }

            }

          

return cryRpt;

        Image may be NSFW.
Clik here to view.
9-15-2014 11-46-55 AM.png

 

Wondering

1. Those reports where I get errors are copy of other report which is working fine with .net, so why do I get connection error?

2. This same connection info is used for all the reports. If there is a  connection problem then I should be getting the same error in all reports but I don't.

 

Could you please help me to figure out whats the real problem is.

 

Crystal Report XI

Visual studio: 2012

MSSQL: 2008 R2

Crystal Report: 11.0.0.2495 [SP: 4]

.Net Version: 4

Crystal Decision dll version: 13.0.2000.0

 

 

Thank you

Lakpa


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>