2012-08-08 199 views
0

我在live server上部署了crystal report。那份報告在我的地方機器上正常工作。Crystal Report Loading Issue

當我上傳了現場服務器是問我的服務器日誌,詳細,所以我有寫代碼按以下

 Dim I As Integer 
     Dim LogonInfo As String() 
     Dim Server As String = "", Database As String = "", User As String = "", Pwd As String = "" 
     LogonInfo = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString.Split(";") 
     For i = 0 To LogonInfo.Length - 1 
      Dim strTemp As String() = LogonInfo(i).Split("=") 
      Select Case strTemp(0).ToLower() 
       Case "server" 
        Server = strTemp(1) 
        Exit Select 
       Case "database" 
        Database = strTemp(1) 
        Exit Select 
       Case "user id" 
        User = strTemp(1) 
        Exit Select 
       Case "password" 
        Pwd = strTemp(1) 
        Exit Select 
      End Select 
     Next 
     CRViewer.ReportSource = rptName 

     Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo() 
     myConnectionInfo.DatabaseName = Database 
     myConnectionInfo.UserID = User 
     myConnectionInfo.Password = Pwd 
     myConnectionInfo.IntegratedSecurity = True 
     Dim myTableLogOnInfos As TableLogOnInfos = CRViewer.LogOnInfo() 
     For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos 
      myTableLogOnInfo.ConnectionInfo = myConnectionInfo 
     Next 

不過它所需要的憑據。 這可能是什麼解決方案?

回答

1

可能會對你有幫助。

protected void Default() 
{ 
    string _strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); 

    SqlConnectionStringBuilder _sqlcon = new SqlConnectionStringBuilder(_strConn); 
    myLogOnInfo.ConnectionInfo.ServerName = _sqlcon.DataSource; 
    myLogOnInfo.ConnectionInfo.DatabaseName = _sqlcon.InitialCatalog; 
    myLogOnInfo.ConnectionInfo.UserID = _sqlcon.UserID; 
    myLogOnInfo.ConnectionInfo.Password = _sqlcon.Password; 
    rptClients.LogOnInfo = new TableLogOnInfos(); 
    rptClients.LogOnInfo.Add(myLogOnInfo); 
} 

這適用於我。