简体   繁体   中英

Crystal Reports login error?

I make a report with the help of http://helpcentral.componentone.com/CS/winforms_31/b/windev/archive/2011/03/03/using-c1barcode-in-crystal-reports.aspx site.

Until drag drop the filed from Field Explorer is nicely work. But at runtime Loin form cross the way.

My connection string is

connectionString="server=192.168.1.100;User Id=root;database=cms;Persist Security Info=True"

How to close this login?

在此处输入图像描述

If any more information is needed, comment here! I will explain step by step!

You need to iterate through each of your Report tables and set the Data Source at runtime.

TableLogOnInfo logOnInfo;
foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in report.Database.Tables)
{
  logOnInfo= tbCurrent.LogOnInfo;
  logOnInfo.ConnectionInfo.DatabaseName = "MyDatabaseName";
  logOnInfo.ConnectionInfo.UserID = "UserId";
  logOnInfo.ConnectionInfo.Password = "secretpassword";
  logOnInfo.ConnectionInfo.ServerName = "SQLServer";
  logOnInfo.ConnectionInfo.Type = ConnectionInfoType.SQL;
  tbCurrent.ApplyLogOnInfo(logOnInfo);
}

Also, you may have to set the Location property of the table object. It may only be a problem with Oracle (because of schemas).

tbCurrent.Location = tbCurrent.Name

This code doesn't really make sense because, if you run in debug mode and inspect Location, it will already have the value you are setting with the Name property. However, you MUST set this for Crystal to work properly. My guess on what is going on is that Crystal is setting the Schema name in the Location property (even though we don't supply it, it must know it in the background), but if you don't set the Location property, Crystal will not work properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM