您好我有一个关于C#程序的问题,我必须在C#软件中使用Crystal报表进行打印我的问题是当我打印Crystal报表询问数据库登录参数时,如何禁用它?谢谢
下面我把代码和错误的图片
代码和错误:
Errore 2方法:
答案 0 :(得分:1)
使用SetDatabaseLogon函数
Myreport.SetDatabaseLogon("username", "password", "server", "dbname", false);
如果SetDatabaseLogon功能不起作用...手动为报告中的每个表分配连接详细信息
ConnectionInfo connInfo = new ConnectionInfo();
connInfo.ServerName = "Driver={Adaptive Server Enterprise};Server=x.x.x.x;Port=x;";
connInfo.UserID = "username";
connInfo.Password = "password";
TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();
tableLogOnInfo.ConnectionInfo = connInfo;
foreach(Table table in reportDoc.Database.Tables)
{
table.ApplyLogOnInfo(tableLogOnInfo);
table.LogOnInfo.ConnectionInfo.ServerName = connInfo.ServerName;
table.LogOnInfo.ConnectionInfo.DatabaseName = connInfo.DatabaseName;
table.LogOnInfo.ConnectionInfo.UserID = connInfo.UserID;
table.LogOnInfo.ConnectionInfo.Password = connInfo.Password;
// Apply the schema name to the table's location
table.Location = "dbo." + table.Location;
}