通过Web.config与crystalReports的连接问题 [英] Connection issues to crystalReports through Web.config

查看:54
本文介绍了通过Web.config与crystalReports的连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,

我从web.config文件连接到Crystal报表时遇到问题.

我的.aspx页在下面给出.

Good Evening,

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

my .aspx page is given below.

<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>




我的aspx.cs页面如下.




and my aspx.cs page is given below.

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


我的web.config文件如下所示.


my web.config file is given below.

<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.....

推荐答案

我不是100%肯定(这已经很长时间了,我我的systelm上没有安装CR以进行测试),但是您在web.config中使用了SQL连接字符串,但是该错误抱怨OLEDB错误.您的报告是使用OLEDB连接进行的吗?如果是这样,可能是您需要将不同的数据传递给login方法,该方法是否有重载?

无论如何,这看起来都是第一个地方.

希望对您有所帮助.
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.


这篇关于通过Web.config与crystalReports的连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆