Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: database login prompt Post Reply Post New Topic
Author Message
anyulled
Newbie
Newbie
Avatar

Joined: 15 Jul 2009
Location: Venezuela
Online Status: Offline
Posts: 1
Quote anyulled Replybullet Topic: database login prompt
    Posted: 15 Jul 2009 at 8:01am
Hi everyone, I created a crystal report viewer and I have it to load some report with subreports and a dataset filled with all the data the report needs.

My thing is everytime I try to display the report it prompts a dialog box asking for database authentication, which I don't need cause i'm passing an already filled Dataset.

My code is this:

            TableLogOnInfo logOnInfo = new TableLogOnInfo();
            int i = 0;
            ReportDocument rpt = new ReportDocument();
            String SQL1 = "";
            SQL1 = mvarRutaReporte;

            try
            {
                logOnInfo.ConnectionInfo.ServerName = mvarNombreServidor;
                logOnInfo.ConnectionInfo.DatabaseName = mvarNombreBD;
                logOnInfo.ConnectionInfo.UserID = mvarUsuarioBD;
                logOnInfo.ConnectionInfo.Password = mvarClave;
                rpt.Load(SQL1);
                rpt.SetDataSource(clsReportes.dsReporte);

                foreach (Table tabla in rpt.Database.Tables)
                {
                    tabla.ApplyLogOnInfo(logOnInfo);
                    if (tabla.TestConnectivity())
                    {
                        MessageBox.Show("Error en la Coneccion de las tablas del reporte!!!", "S.I.M.M.");
                    }
                }
                #endregion
                #region autenticando los subreportes
                foreach (ReportDocument Subreporte in rpt.Subreports)
                {
                    Subreporte.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
                    if (Subreporte.Database.Tables[0].TestConnectivity())
                    {
                        MessageBox.Show("Error en la Coneccion de las tablas del SubReporte!!!", "S.I.M.M.");
                    }
                }
           
                this.crtReportes.ReportSource = rpt;
           
            }
            catch (Exception a)
            {
                MessageBox.Show(a.ToString());
            }


I even tried to handle the authentication with this routine:

            Sections crSections;
            ReportDocument crReportDocument, crSubreportDocument;
            SubreportObject crSubreportObject;
            ReportObjects crReportObjects;
            ConnectionInfo crConnectionInfo;
            Database crDatabase;
            Tables crTables;
            TableLogOnInfo crTableLogOnInfo;
            crReportDocument = new ReportDocument();
            crReportDocument.Load(RutaReporte);
            crReportDocument.SetDataSource(clsReportes.dsReporte);
            crDatabase = crReportDocument.Database;
            crTables = crDatabase.Tables;
            crConnectionInfo = new ConnectionInfo();
            crConnectionInfo.ServerName = NombreServidor ;
            crConnectionInfo.DatabaseName = NombreBD;
            crConnectionInfo.UserID = UsuarioBD;
            crConnectionInfo.Password = Clave;
            foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
            {
                crTableLogOnInfo = aTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                aTable.ApplyLogOnInfo(crTableLogOnInfo);
            }
            // Para los reportes que poseen subreportes
            // pongo el objeto seccion del la seccion actual del reporte
            crSections = crReportDocument.ReportDefinition.Sections;
            // busco en todas las secciones el objeto reporte
            foreach (Section crSection in crSections)
            {
                crReportObjects = crSection.ReportObjects;
                //busco en todos los reportes por subreportes
                foreach (ReportObject crReportObject in crReportObjects)
                {
                    if (crReportObject.Kind == ReportObjectKind.SubreportObject)
                    {
                        crSubreportObject = (SubreportObject)crReportObject;
                        //abro el subreporte y me logeo con los datos del reporte general
                        crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
                        crDatabase = crSubreportDocument.Database;
                        crTables = crDatabase.Tables;
                        foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
                        {
                            crTableLogOnInfo = aTable.LogOnInfo;
                            crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                            aTable.ApplyLogOnInfo(crTableLogOnInfo);
                        }
                    }
                }
            }


Any help?
lol
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.