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

Who is Participating?
janmariniConnect With a Mentor Commented:

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)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.