2017-04-14 73 views
0

您好,我有一個關於C#程序的問題,我必須在C#軟件中使用Crystal報告進行打印。我的問題是,當我打印Crystal報告時詢問數據庫登錄參數,怎麼能我禁用這個?謝謝Crystal Report詢問數據庫參數登錄C#

下面我把代碼和錯誤

代碼和錯誤的畫面:

enter image description here

Errore 2方法:

enter image description here

回答

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; 
    } 
+0

然後用第一種方法總是問我的參數,用第二種方法給我分配的連接細節,每個表上圖中的錯誤 – riki

相關問題