mike55 Posted September 22, 2004 Posted September 22, 2004 :mad: :( :confused: Hi all Ok i have done the following... 1. Right clicked and selected add new item 2. Selected crystal reports option and left the name the same. 3. Used the reporting wizard to set up the report. 4. Expanded the ODBC option, select SQL Server option and click next. 5. Next page tells me that the Server is "SQL Server", and the User ID is "Administrator", while the password field and database dropdown list are blank. I also have the option of checking a checkbox which indocates whether it is a trusted connection or not. 6. In this case i fill up the boxeswith the following data Server = "SQL Server", User ID = "Administrator", Password = "********" and i tick the trusted connection option and finally the database is set to the "Northwind" database. I the click Finish. 7. I then expand the Northwind option that has appeared under the SQL Server option in the initial screen, i continue to expand untill i have located the tables option which i also expand and select the employees table and then click the 'insert' button. 8. I then click next and select the first three columns, EmployeeID, FirstName, LastName. I then click next and go to the groupby option where i select the EmployeeID field. 9. I then click finish. 10. Next i take place the following section of code and place it behind a button... Imports System.Web.UI.WebControls Imports CrystalDecisions.Shared Imports CrystalDecisions.CrystalReports.Engine Dim oRpt As New CrystalReport1 'name of my report Dim myExportOptions As CrystalDecisions.Shared.ExportOptions Dim myDiskFilesDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions Dim myExportFile As String 'myExportFile = "C:\temp\PDF " & Session.SessionID.ToString & ".pdf" myExportFile = "C:\temp\PDF rptCrystalTest.pdf" myDiskFilesDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions myDiskFilesDestinationOptions.DiskFileName = myExportFile myExportOptions = oRpt.ExportOptions With myExportOptions .DestinationOptions = myDiskFilesDestinationOptions .ExportDestinationType = .ExportDestinationType.DiskFile .ExportFormatType = .ExportFormatType.PortableDocFormat End With oRpt.Export() Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.WriteFile(myExportFile) Response.Flush() Response.Close() System.IO.File.Delete(myExportFile) 11. When the code runs, it should take the crystal report that i designed and put into pdf format in the location stecified. The problem is that when i run the project and click the button, i get a message telling me that... Server Error, ...Logon failed. Can anyone suggest where i am going wrong. In relation to the user name and password, i have tried the above proceedure without username and password, and with username but no password, to same some (but still the same problem). I don't know why .net net want the username to be "Administrator" as the database does not have a username or password. Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
college_amy Posted October 26, 2005 Posted October 26, 2005 Did you ever figure this out? I am having the exact same Logon Error problem as you were/are having. Amy Quote
barski Posted October 26, 2005 Posted October 26, 2005 oRpt.SetDataBaseLogon(); or you could use the tables logon but i think that crystal 11 handle table logons differently so it will throw errors Quote
mike55 Posted November 2, 2005 Author Posted November 2, 2005 Hi college_amy, only after spotting your posting now. Here is the code that I used, hopefully it may be of some use to you. Dim oRpt As New rptMessages Try 'The following try catch statement is responsible for generating the report in a .pdf format. Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo crLogonInfo = oRpt.Database.Tables(0).LogOnInfo crLogonInfo.ConnectionInfo.ServerName = "(local)" crLogonInfo.ConnectionInfo.DatabaseName = "NorthWind" crLogonInfo.ConnectionInfo.UserID = "sa" crLogonInfo.ConnectionInfo.Password = "~~~" oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo) Dim myExportOptions As CrystalDecisions.Shared.ExportOptions Dim myDiskFilesDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions Dim myExportFile As String myExportFile = "C:\temp\PDF " & Session.SessionID.ToString & ".pdf" myDiskFilesDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions myDiskFilesDestinationOptions.DiskFileName = myExportFile myExportOptions = oRpt.ExportOptions With myExportOptions .DestinationOptions = myDiskFilesDestinationOptions .ExportDestinationType = .ExportDestinationType.DiskFile .ExportFormatType = .ExportFormatType.PortableDocFormat End With oRpt.Export() Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.WriteFile(myExportFile) Response.Flush() Response.Close() oRpt.Dispose() If Not oRpt Is Nothing Then oRpt = Nothing End If System.IO.File.Delete(myExportFile) Catch ex As Exception End Try End Sub Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.