Crystal Report logon fails on webserver

来源:http://www.imcoder.org/report/192716.htm

 

Q:

Hi all,

Since we upgrated from sqlserver2000 to sqlserver2005 my reports won't work anymore on the webserver. On my dev machine they work perfect.
I use an OLE DB connection to the server, I already edited the provider to SQLOLEDB (standard SQLCLNT).

I receive this error:

Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. SQL State: 08001 Native Error: Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Invalid connection string attribute SQL State: 01S00 Error in File C:\WINDOWS\TEMP\rptVacatureDetail {D27274A5-95FE-4A8F-A5E3-C1CF7A584B06}.rpt: Unable to connect: incorrect log on parameters.


The following code loads & connects the report

Dim rapport As New ReportDocument
rapport.Load(mapReports & "rptVacatureDetail.rpt")
rapport.SetDatabaseLogon("loginname", "password", "severname", "database")
paramField.ParameterFieldName =
"@vac_id"
discreteVal.Value = Request.QueryString("vac_id")
paramField.CurrentValues.Add(discreteVal)
paramFields.Add(paramField)
reportviewer.ParameterFieldInfo = paramFields

reportviewer.ReportSource = rapport

This simple code has always worked for me, it still does on my devmachine but as soon the application is published the reports won't show

Thanks in advance!

A:

Use this code

 

    Dim conInfo As New TableLogOnInfo

Try objReport.Load(Server.MapPath(sReportName)) conInfo.ConnectionInfo.UserID = <UserName> conInfo.ConnectionInfo.Password = <Password> 'conInfo.ConnectionInfo.IntegratedSecurity = True conInfo.ConnectionInfo.ServerName = <ServerName> ConInfo.ConnectionInfo.DatabaseName = <Database> For intCounter = 0 To rapport .Database.Tables.Count - 1
rapport .Database.Tables(intCounter).ApplyLogOnInfo(ConInfo)
Next

For
index = 0 To rapport .ReportDefinition.Sections.Count - 1
For intCounter = 0 To rapport .ReportDefinition.Sections(index).ReportObjects.Count - 1
With rapport .ReportDefinition.Sections(index)
If .ReportObjects(intCounter).Kind = ReportObjectKind.SubreportObject Then mySubReportObject = CType(.ReportObjects(intCounter), SubreportObject)
mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
For intCounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(conInfo)
mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(conInfo)
Next
End If
End With
Next
Next


Return True
Catch
ex As System.Exception
'MsgBox(ex.Message) End Try
End Function
 
A:

I have the same problem.

This is my code in C#.

ReportDocument cryRpt = new ReportDocument();

TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();

TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();

ConnectionInfo crConnectionInfo = new ConnectionInfo();

Tables CrTables;

 

cryRpt.Load(Server.MapPath(
"CrystalOT.rpt"));

 

{

crConnectionInfo.IntegratedSecurity =
true;

crConnectionInfo.ServerName = "221.23.0.15";

crConnectionInfo.DatabaseName = "UATKTBLEASING";

crConnectionInfo.UserID = "sa";

crConnectionInfo.Password = "ktbladmin";

}

 

CrTables = cryRpt.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)

{

crtableLogoninfo = CrTable.LogOnInfo;

crtableLogoninfo.ConnectionInfo = crConnectionInfo;

CrTable.ApplyLogOnInfo(crtableLogoninfo);

}

 

CrystalReportViewer1.ReportSource = cryRpt;

CrystalReportViewer1.DataBind();

CrystalReportViewer1.RefreshReport();

 

Thank you for your help

A:

I used your code but it is still not working. I also ran into some parameter problems wich I solved via a patch from crystal reports (://support.businessobjects.com/library/kbase/articles/c2018840.asp )

My code now

Dim conInfo As New TableLogOnInfo
Dim intcounter, intcounter1, index As Int16

Try
rapport.Load(mapReports & "persoon_algemeen.rpt")
conInfo.ConnectionInfo.UserID =
"login"
conInfo.ConnectionInfo.Password = "paswoord"
conInfo.ConnectionInfo.IntegratedSecurity = False
conInfo.ConnectionInfo.ServerName = "server"
conInfo.ConnectionInfo.DatabaseName = "database"
For intcounter = 0 To rapport.Database.Tables.Count - 1
rapport.Database.Tables(intcounter).ApplyLogOnInfo(conInfo)
Next

For index = 0 To rapport.ReportDefinition.Sections.Count - 1
For intcounter = 0 To rapport.ReportDefinition.Sections(index).ReportObjects.Count - 1
With rapport.ReportDefinition.Sections(index)
If .ReportObjects(intcounter).Kind = ReportObjectKind.SubreportObject Then
Dim mySubReportObject As SubreportObject
Dim mySubRepDoc As ReportDocument
mySubReportObject =
CType(.ReportObjects(intcounter), SubreportObject)
mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
For intcounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
mySubRepDoc.Database.Tables(intcounter1).ApplyLogOnInfo(conInfo)
Next

End If
End With
Next
Next
paramField.ParameterValueType = ParameterValueKind.StringParameter
paramField.ParameterFieldName =
"@p_id"
discreteVal.Value = Session.Contents("persoon_id")
paramField.CurrentValues.Add(discreteVal)
paramFields.Add(paramField)
crvCV.ParameterFieldInfo = paramFields
crvCV.ReportSource = rapport
Catch ex As System.Exception
MsgBox(ex.Message)
End Try

 

Can anybody help?

A:

Problem solved:

conInfo.ConnectionInfo.ServerName = "server"

changed into

conInfo.ConnectionInfo.ServerName = "ip address"

Damn this error has cost a lot of time and $

posted @ 2008-08-11 13:04  KK in cnblog  阅读(739)  评论(0编辑  收藏  举报