Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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;

       

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

Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question