带有ms-access连接问题的水晶报表 [英] crystal report with ms-access connection issue

查看:66
本文介绍了带有ms-access连接问题的水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我在C#中有一个窗口应用程序,在此我使用Crystal Report进行报告.
我在单击按钮以显示报告时编写了以下代码:

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(); 



我正在使用ms-access数据库并将mdb文件放到debug文件夹中,但是当我运行它时,它要求我提供用户名和密码,但是我没有此数据库的任何用户名和密码.并且登录失败.那我该如何连接呢?

请帮助
感谢



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

推荐答案

在创建报告时使用了哪个数据提供者...
您必须使用

Database Expert中的Access/Excel(DAO)

因此它不会要求提供凭据...
while creating report which dataprovider you used...
you have to use

Access/Excel(DAO) in Database Expert

So it will not ask for credentials...


这篇关于带有ms-access连接问题的水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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