我在实时服务器上部署了水晶报告。该报告在我的本地机器上正常工作。
当我通过实时服务器上传时,它要求我提供服务器登录详细信息,以便我按照以下编写代码
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
还是要求凭证。 有什么可以解决这个问题?
答案 0 :(得分: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);
}
这对我有用。
答案 1 :(得分:0)
我有一些CR的扩展方法,我用VB.Net编写,可能对你有帮助。我通常不使用查看器,但只要您有权访问ReportDocument,就可以实现这一目的:
使用它们的扩展和示例(通常我使用ADO连接):
http://www.blakepell.com/Main/BlogEntry.aspx?EntryID=e2fcdcf9-312e-4911-8572-20178c94660b