0

我已经在实时服务器上部署了水晶报表。该报告在我的本地机器上正常工作。

当我通过实时服务器上传时,它要求我提供服务器登录详细信息,因此我按照以下方式编写代码

        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

它仍然要求 credential 。这可能是什么解决方案?

4

2 回答 2

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);
}

这对我有用。

于 2012-08-30T17:38:55.993 回答
0

我有一些在 VB.Net 中编写的 CR 扩展方法,可能会对您有所帮助。我通常不使用查看器,但只要您可以访问 ReportDocument,就可以解决问题:

使用它们的扩展和示例(通常我使用 ADO 连接这些):

http://www.blakepell.com/Main/BlogEntry.aspx?EntryID=e2fcdcf9-312e-4911-8572-20178c94660b

于 2012-08-31T23:04:53.673 回答