Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# VS2010 Crystal Reports在通过代码发送数据集时要求登录。_C#_Visual Studio 2010_Login_Crystal Reports_Dataset - Fatal编程技术网

C# VS2010 Crystal Reports在通过代码发送数据集时要求登录。

C# VS2010 Crystal Reports在通过代码发送数据集时要求登录。,c#,visual-studio-2010,login,crystal-reports,dataset,C#,Visual Studio 2010,Login,Crystal Reports,Dataset,我已经在项目中创建了数据集(.xsd)和报表(.rpt)文件。我通过代码填充数据集,然后将其设置为报表的SetDataSource,它显示第一页,但其他任何内容(如下一页或导出)都会触发登录弹出窗口 我做错了什么?没有用户或通行证(我猜),因为我没有直接访问数据库 List<TBL_PAG_SEGURO_VENDASFields> list = controle.GetRelatorioAll(); vendasDS ds = new vendasDS

我已经在项目中创建了数据集(.xsd)和报表(.rpt)文件。我通过代码填充数据集,然后将其设置为报表的SetDataSource,它显示第一页,但其他任何内容(如下一页或导出)都会触发登录弹出窗口

我做错了什么?没有用户或通行证(我猜),因为我没有直接访问数据库

        List<TBL_PAG_SEGURO_VENDASFields> list = controle.GetRelatorioAll();
        vendasDS ds = new vendasDS();
        foreach(TBL_PAG_SEGURO_VENDASFields item in list)
        {
            DataRow row = ds.Tables["vendas"].NewRow();
            row[0] = item.RAZAO_SOCIAL;
            row[1] = item.DT_VENDA;
            row[2] = item.TRANSACAO_ID;
            row[3] = item.SITUACAO;
            row[4] = item.NOME;
            row[5] = item.VALOR_VENDA;
            row[6] = item.DT_LIBERACAO_PAGTO;
            row[7] = item.HISTORICO_ALTERACOES;
            row[8] = item.DT_FINAL_SERVICE;
            ds.Tables["vendas"].Rows.Add(row);
        }
        ReportDocument reportDocument = new ReportDocument();
        string filePath = Request.PhysicalApplicationPath + "Recursos/Reports/vendasCR.rpt";                
        reportDocument.Load(filePath);
        reportDocument.SetDataSource(ds);
        crv_Vendas.ReportSource = reportDocument;
List List=controle.GetRelatorioAll();
vendasDS=新的vendasDS();
foreach(列表中的TBL_PAG_SEGURO_VENDASFields项)
{
DataRow row=ds.Tables[“vendas”].NewRow();
第[0]行=item.RAZAO_SOCIAL;
第[1]行=item.DT_VENDA;
第[2]行=item.TRANSACAO\u ID;
第[3]行=item.SITUACAO;
第[4]行=item.NOME;
第[5]行=item.VALOR_VENDA;
第[6]行=item.DT_LIBERACAO_PAGTO;
第[7]行=item.HISTORICO_ALTERACOES;
第[8]行=item.DT\u最终服务;
ds.Tables[“vendas”].Rows.Add(row);
}
ReportDocument ReportDocument=新的ReportDocument();
字符串filePath=Request.PhysicalApplicationPath+“Recursos/Reports/vendasCR.rpt”;
reportDocument.Load(文件路径);
reportDocument.SetDataSource(ds);
crv_Vendas.ReportSource=reportDocument;

我的建议是,要么在设计时设置凭证。但是在c代码中设置运行时的凭证很好。原因是您在设计时设置了凭据,它适用于您的本地环境,但在部署时,凭据是否相同

不,这就是我们设定c代码的原因。在给定的链接中,将解释如何为主报表、子报表及其表设置凭据

   Dim myTables As Tables = myReportDocument.Database.Tables
   ' The login information used to connect to the database
   Dim myTableLogonInfo As TableLogOnInfo

   ' Loop through each of the tables found
   For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
      ' Set the login information used to connect to the database
      myTableLogonInfo = myTable.LogOnInfo

      ' Set the connection credentials
      myTableLogonInfo.ConnectionInfo = myConnectionInfo

      ' Apply this to the table found
      myTable.ApplyLogOnInfo(myTableLogonInfo)

   Next


代码是正确的,我所做的错误是在我的报告中使用自定义连接设置数据集文件,重新创建它,将数据集设置为ADO.NET连接,并在Page_Init内进行代码调用,从而解决了我的问题