2
votes

I've created a Dataset (.xsd) and Report (.rpt) files in my project. I fill my Dataset via code and then set it to the Report's SetDataSource, it shows the first page fine but anything else, like next page or export triggers a login popup.

What am I doing wrong? Theres no user or pass (I guess) since I'm not making a direct access to the DB.

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

2 Answers

1
votes

What I suggest , either you are set credential at design time. But good to set credential at run-time in your c# code. The reason is design time you set the credential, it work for your local environment, but when you deploy, is that the same credentials?

No, that why we set at c# code. As given link, there is explain how to set credentials for main report , sub-report and its tables.

   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

Dynamically set Crystal Report still asks for db login

Set credential of crystal report at run-time

1
votes

The code is right, what I was doing wrong is setting the dataset file with a custom connection in my report, recreated it setting the dataset as ADO.NET Connection and making the code call inside Page_Init solved my problem.