0
您好,我有一个关于C#程序的问题,我必须在C#软件中使用Crystal报告进行打印。我的问题是,当我打印Crystal报告时询问数据库登录参数,怎么能我禁用这个?谢谢Crystal Report询问数据库参数登录C#
下面我把代码和错误
代码和错误的画面:
Errore 2方法:
您好,我有一个关于C#程序的问题,我必须在C#软件中使用Crystal报告进行打印。我的问题是,当我打印Crystal报告时询问数据库登录参数,怎么能我禁用这个?谢谢Crystal Report询问数据库参数登录C#
下面我把代码和错误
代码和错误的画面:
Errore 2方法:
使用 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;
}
然后用第一种方法总是问我的参数,用第二种方法给我分配的连接细节,每个表上图中的错误 – riki