I am trying to install some reports on a web server using CR.NET, and can't get them to run using SQL Server. If I use an Access database, they run fine. I have tried 2 different methods of coding, and I get different errors. Here are the 2 code methods.
------------------------------------------------------
' This code generates "Logon Failed" message
Dim rpt As New CrystalReport1
SqlConnection1.ConnectionString = "user id=myuser;password=mypassword;data source=myserver;persist security info=False;initial catalog=mydatabase"
SqlDataAdapter1.Fill(DataSet1, "AddressType"
rpt.SetDataSource(DataSet1)
CrystalReportViewer1.ReportSource = rpt ' Error occurs here - "Logon Failed"
'DataGrid1.DataSource = DataSet1 ' I can successfully display the
'DataGrid1.DataBind() ' dataset in a datagrid
'Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
NOTE: If I comment out the line where I set the ReportSource, I can successfully display the dataset in a datagrid.
--------------------------------
This is the second method used
----------------------------------
' This code generates an "Invalid Table Number" error on test server.
' It works in IDE.
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim crReportDocument As New CrystalReport1
'Set the ConnectionInfo properties for logging on to the Database
With crConnectionInfo
.ServerName = "myserver"
.DatabaseName = "mydatabase"
.UserID = "myuser"
.Password = "mypassword"
End With
CrTables = crReportDocument.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
CrTable.Location = "CMTP_TEST.dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf("." + 1)
Next
'Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument
' Exception Details: CrystalDecisions.CrystalReports.Engine.InvalidArgumentException:
' Error in File C:\DOCUME~1\WEBTEST\ASPNET\LOCALS~1\Temp\temp_555bef2a-0da7-4fbb-9704-80a6ab8fe44e.rpt: Invalid table number.
-----------------------
Thanks
------------------------------------------------------
' This code generates "Logon Failed" message
Dim rpt As New CrystalReport1
SqlConnection1.ConnectionString = "user id=myuser;password=mypassword;data source=myserver;persist security info=False;initial catalog=mydatabase"
SqlDataAdapter1.Fill(DataSet1, "AddressType"
rpt.SetDataSource(DataSet1)
CrystalReportViewer1.ReportSource = rpt ' Error occurs here - "Logon Failed"
'DataGrid1.DataSource = DataSet1 ' I can successfully display the
'DataGrid1.DataBind() ' dataset in a datagrid
'Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
NOTE: If I comment out the line where I set the ReportSource, I can successfully display the dataset in a datagrid.
--------------------------------
This is the second method used
----------------------------------
' This code generates an "Invalid Table Number" error on test server.
' It works in IDE.
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim crReportDocument As New CrystalReport1
'Set the ConnectionInfo properties for logging on to the Database
With crConnectionInfo
.ServerName = "myserver"
.DatabaseName = "mydatabase"
.UserID = "myuser"
.Password = "mypassword"
End With
CrTables = crReportDocument.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
CrTable.Location = "CMTP_TEST.dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf("." + 1)
Next
'Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument
' Exception Details: CrystalDecisions.CrystalReports.Engine.InvalidArgumentException:
' Error in File C:\DOCUME~1\WEBTEST\ASPNET\LOCALS~1\Temp\temp_555bef2a-0da7-4fbb-9704-80a6ab8fe44e.rpt: Invalid table number.
-----------------------
Thanks