Crystal Report-无法登录到数据库c#

时间:2019-04-02 08:25:20

标签: c# sql-server winforms crystal-reports

我正在WinFrom上使用Crystal报表(该报表仅包含1个表)。

我有两台机器,在第一台机器上一切正常(Windows 10)。 但是在第二台(Windows 7)上,我似乎无法登录到数据库。

我已将整个项目照原样从工作机器复制到有问题的机器,但问题仍然存在。 没有错误信息,没有异常,只是一些通用的“登录失败,请重试”

据我研究,机器之间的唯一区别是DB(Microsoft SQL服务器)本身,在数据库名称旁边,似乎在工作机器中不需要属性IntegratedSecurity(与或没有此属性)。但是在有问题的计算机上,似乎需要此属性,但是即使我设置了IntegratedSecurity = true,问题仍然存在。

我在herehere处找了东西

public static void printReport(string id)
{           
   using (var frmPrint = new FrmPrint(id))
   {
        SetTableConnectionInfo(frmPrint);

        frmPrint.palletLablePaving.SetParameterValue(0, id);
#if DEBUG
        frmPrint.crystalReportViewer1.ReportSource = frmPrint.palletLablePaving;
        frmPrint.ShowDialog();
#else
        frmPrint.palletLablePaving.PrintToPrinter(nCopies: 1, collated: false, startPageN: 0, endPageN: 0);
#endif
     }
  }


private static void SetTableConnectionInfo(FrmPrint frmPrint)
{

     foreach (Table table in frmPrint.palletLablePaving.Database.Tables)
     {
         // Get the ConnectionInfo Object.
            var logOnInfo = table.LogOnInfo;
            var connectionInfo = logOnInfo.ConnectionInfo;

              // Set the Connection parameters.
              connectionInfo.DatabaseName = "APP5D";
              connectionInfo.ServerName = @".\YP_LINE5_DRY";
              connectionInfo.UserID = "admin";
              connectionInfo.Password = "myPssword";
              connectionInfo.IntegratedSecurity = true; // not affecting the result
              table.ApplyLogOnInfo(logOnInfo);
       }

}

PS 我无法更改报表或数据库属性中的任何内容

修改 使用SQL Server版本11(2012)的工作计算机和使用版本12(2014)有问题的计算机

0 个答案:

没有答案