Access (OLEDB), Crystal, Export to PDF?

robplatt

Active member
Joined
Jul 14, 2006
Messages
39
I have a report embedded in my application. I can view it within my application at runtime using these two lines here:
Code:
CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.Password = Chr(10) + "mypassword"
CrystalReportViewer1.SelectionFormula = "({OrderHistory.OrderNumber}=""" & ListView5.SelectedItems(0).Text & """)"

I do not have a username/password for my database file, its just a database level password. The rest of my application uses it just fine. I can open my crystal report just fine. However. I need to be able to automate the export to pdf option. ( yes i know its available on the view window but i need to be able to build a pdf and email it in the background)

im trying to do it with the following code

Code:
Report.SetDatabaseLogon("", "mypassword")
Report.RecordSelectionFormula = "({OrderHistory.OrderNumber}=""" & ListView5.SelectedItems(0).Text & """)"
Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "test.pdf")

have tried this too

Code:
Report.Database.Tables("OrderHistory").LogOnInfo.ConnectionInfo.Password = Chr(10) + "mypassword" 
           Report.Database.Tables("OrderHistoryList").LogOnInfo.ConnectionInfo.Password = Chr(10) + "mypassword"

Im stuck. I can not pass the password correctly using the above methods. I have read so much and tried so many different examples, but they were all for workgroup accounts and not a database level pw. please help....
 
Solved...

Code:
        Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
        crLogonInfo = Report.Database.Tables(0).LogOnInfo
        crLogonInfo.ConnectionInfo.Password = Chr(10) + "mypasword"
        Report.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)

        Try
            Report.RecordSelectionFormula = "({OrderHistory.OrderNumber}=""" & ListView5.SelectedItems(0).Text & """)"
            Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, saveFile.FileName)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
 
Back
Top