Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2265
  • Last Modified:

Crystal Reports Connection string from web.config

Dear Experts
I am using VS.NET 2005, ASP.NET 2.0, C#, SQLSERVER2000
I want to use Crystal Reports, but the problem I found is that,
I can’t give to the report while I am creating it from the wizard the connection string in the web.config
I need help or any ideas thank you

Thank you

1 Solution

I'm using VS.NET 2002 and ASP.NET 1.0 and VB, and CR 9.0 so things might be different... but here's some snippets on how I'm using settings from Web.Config to load my report...  When creating the report I used OLEDB(ADO), Microsoft OLE DB Provider for for SQL Server, and connect to my development DB.  The code below allows me to change that connection info:

In Web.Config:

      <!-- connection string -->
      <add key="strServer" value="YourServer" />
      <add key="strDBase" value="YourDB" />
      <add key="strUID" value="YourUID" />
      <add key="StrPWD" value="YourPassword" />

In my module to Logon to the report:

Public Sub LogonReport(ByVal rptReport As CrystalDecisions.CrystalReports.Engine.ReportDocument)
'Logs into the tables in the report
        crReportDocument = rptReport
        crDataBase = crReportDocument.Database
        crTables = crDataBase.Tables
        For Each crTable In crTables
            With crConnInfo
                .ServerName = ConfigurationSettings.AppSettings("strServer")
                .DatabaseName = ConfigurationSettings.AppSettings("strDBase")
                .UserID = ConfigurationSettings.AppSettings("strUID")
                .Password = ConfigurationSettings.AppSettings("strPWD")
            End With

            crTableLogonInfo = crTable.LogOnInfo
            crTableLogonInfo.ConnectionInfo = crConnInfo
            crTable.Location = strDBase & ".dbo." & crTable.Name
Also logon to subreport tables....

In my .aspx page to load the report:

crReportDocument.Load(Server.MapPath("") & ReportName)
Call LogonReport(crReportDocument)

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now