Source: 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 isStill 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
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
ConInfo. ConnectionInfo. ServerName = "ip address"
Damn this error has cost a lot of time and $