robplatt Posted August 8, 2006 Posted August 8, 2006 I have a report embedded in my application. I can view it within my application at runtime using these two lines here: 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 Report.SetDatabaseLogon("", "mypassword") Report.RecordSelectionFormula = "({OrderHistory.OrderNumber}=""" & ListView5.SelectedItems(0).Text & """)" Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "test.pdf") have tried this too Report.Database.Tables("OrderHistory").LogOnInfo.ConnectionInfo.Password = Chr(10) + "mypassword" Report.Database.Tables("OrderHistoryList").LogOnInfo.ConnectionInfo.Password = Chr(10) + "mypassword" I'm 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.... Quote
robplatt Posted August 9, 2006 Author Posted August 9, 2006 Solved... 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 Quote
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.