Click here to Skip to main content
16,020,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good Evening,

I have issue with connection to Crystal report from web.config file .

my .aspx page is given below.

XML
<form id="form1" runat="server">
  <div>
  <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
          AutoDataBind="True" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False"
          Height="811px" ReportSourceID="CrystalReportSource1" Width="2594px"></CR:CrystalReportViewer>
      <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
          <Report FileName="Report\RptMonthlyNetSaleByCustomer.rpt">
          </Report>
      </CR:CrystalReportSource>
  </div>
  </form>



and my aspx.cs page is given below.

ASP
protected void Page_Load(object sender, EventArgs e)
   {
       SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(ConfigurationManager.AppSettings["ConnectionString"].ToString());
       TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
       TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
       ConnectionInfo crConnectionInfo = new ConnectionInfo();
       ReportDocument cryRpt = new ReportDocument();
       Tables CrTables;
       cryRpt.Load(Server.MapPath(@"~/Report/RptMonthlyNetSaleByCustomer.rpt"));
       cryRpt.SetDatabaseLogon(SConn.UserID, SConn.Password, SConn.DataSource, SConn.InitialCatalog);
       CrTables = cryRpt.Database.Tables;
       foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
       {

           crtableLogoninfo = CrTable.LogOnInfo;
           crtableLogoninfo.ConnectionInfo = crConnectionInfo;
           CrTable.ApplyLogOnInfo(crtableLogoninfo);
       }
       cryRpt.SetParameterValue("@strIDs", Session["stID"].ToString());
       cryRpt.SetParameterValue("@strdtFromDate", Session["FromDate"].ToString());
       cryRpt.SetParameterValue("@strdtToDate", Session["ToDate"].ToString());
       CrystalReportViewer1.ReportSource = cryRpt;

   }

when i run this report then i got error which is given below.

Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Invalid authorization specification SQL State: 28000 Error in File C:\Users\Vaquas\AppData\Local\Temp\RptMonthlyNetSaleByCustomer {1EA5CF63-EF4B-4B14-9053-FA40442011B2}.rpt: Unable to connect: incorrect log on parameters

my web.config file is given below.

XML
<appSettings>
        <add key="ConnectionString" value="Data Source=HHDVAQUAS;Initial Catalog=DeemahCurrent; User Id=sa;Password=samesame;"/>
        <add key="CrystalImageCleaner-AutoStart" value="true"/>
        <add key="CrystalImageCleaner-Sleep" value="60000"/>
        <add key="CrystalImageCleaner-Age" value="120000"/>
    </appSettings>
    <connectionStrings>
  <add name="ConnectionString" connectionString="Data Source=HHDVAQUAS;Initial Catalog=DeemahCurrent; User Id=sa;Password=samesame;"
   providerName="System.Data.SqlClient" />
  <add name="DeemahTodayConnectionString" connectionString="Data Source=HHDVAQUAS;Initial Catalog=DeemahCurrent; Integrated Security=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>



so please help me how can i do this.....
Posted
Updated 25-May-11 1:38am
v2
Comments
ZeeroC00l 25-May-11 7:38am    
-- added pre tag

1 solution

I'm not 100% sure (it's been a long time and I have no CR installed on my systelm to test), but you're using a SQL connection string in your web.config, yet the error complains about an OLEDB error. Is your report made with an OLEDB connection? If so, it might be you need to pass different data to the login method, are there overloads to this method?

In any case, this looks like a first place to look.

hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900