水晶报表部署连接到mdf文件 [英] Crystal report deployment connect to the mdf file

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

问题描述

大家好,

我已经在应用程序的bin/debug文件夹中复制了数据库的.mdf和.ldf文件,并使用了如下的连接字符串

数据源=.\ SQLEXPRESS; AttachDbFilename = | DataDirectory | \ MyDatabase.mdf;集成安全性= True;用户实例= True
其中MyDatabase =数据库名称
应用程序运行正常,但是在运行时以及创建设置文件后出现新错误.我在设置项目以及bin/release文件夹中复制了.mdf文件和.ldf文件,然后整个应用程序运行正常,但现在我遇到了错误在水晶报表中询问用户名和密码.

请同样建议我.

在此先感谢.

我的代码是:

Hi All,

I have copied .mdf and .ldf files of database in bin/debug folder of my application and used the connection string as follows

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Integrated Security=True;User Instance=True
where MyDatabase=database name
application runs fine but i am getting new error while running and after creating set up file.I copied .mdf file and .ldf file in set up project and also in bin/release folder and then total application runs fine but now i am getting error in crystal report asking for user name and passwords.

Please suggest me for the same.

Thanks in Advance.

My code is:

public void Refreshreport()
{
   //I've added the report file (BalanceCrystalReport.rpt)to my project, 
   //and create an instance of the file. 
   var report = new BalanceCrystalReport();

   foreach (ReportDocument doc in report.Subreports)
   {
           foreach (Table table in doc.Database.Tables)
                table.ApplyLogOnInfo(MyTableLogOnInfo);

           doc.SetDatabaseLogon("", "",".\\SQLEXPRESS", "MyDatabase");
   }
   crystalReportViewer.ReportSource = report;
}

public virtual TableLogOnInfo MyTableLogOnInfo
{
  get
  {
      if(myTableLogOnInfo == null)
      {
          myTableLogOnInfo = new TableLogOnInfo();

          myTableLogOnInfo.ConnectionInfo.ServerName = ".\\SQLEXPRESS";
          myTableLogOnInfo.ConnectionInfo.DatabaseName = "MyDatabase";
          myTableLogOnInfo.ConnectionInfo.UserID = "";
          myTableLogOnInfo.ConnectionInfo.Password = "";
          myTableLogOnInfo.ConnectionInfo.IntegratedSecurity = true;
      }
      return myTableLogOnInfo;
}

推荐答案

尝试在您的连接字符串中添加用户名和密码
try to add username and password in your connection string


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

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