Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks!

I have a window application in c#, in this i m using crystal report for reporting.
I have written the following code on button click to show report:

ReportDocument cryRpt = new ReportDocument();
            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            Tables CrTables ;

            string paths = Path.GetDirectoryName(Application.ExecutablePath) + ".\\myreport.rpt";
            cryRpt.Load(paths);

            crConnectionInfo.ServerName = "";
            crConnectionInfo.DatabaseName = ".\\mydb.mdb";
            crConnectionInfo.UserID = "";
            crConnectionInfo.Password = "";

            CrTables = cryRpt.Database.Tables ;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }

            crystalReportViewer1.ReportSource = cryRpt;
            crystalReportViewer1.Refresh(); 


I am using ms-access database and put the mdb file in the debug folder but when i run this it asks me to give userid and password but i don't have any userid and password for this database. and login fails. Then how can i connect to it?

Please Help
Thanks
Posted

1 solution

while creating report which dataprovider you used...
you have to use

Access/Excel(DAO) in Database Expert

So it will not ask for credentials...
 
Share this answer
 
v2

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