login error - passing data set to crystal reports
I have a web application, I am trying to create a pdf via crystal reports.
this code gives me a login error on the export call, I suspect because I have to pass the user name and password to crystal reports.
THe data set is used, since I want to view/create to pdf only certain record(s) based on user criteria.
If I can't make this work, can I pass a parameter to the crystal report? can I get a code sample? Feel free to email me directly for additional questions.
thanks
Dim doc As New ReportDocument()
Dim rptfile As String = "UAF.rpt"
Dim filename As String = Server.MapPath(rptfile)
doc.Load(filename)
Dim ds As New DataSet()
' retrieve specific disbursement ID
Dim strconn As String = "Driver={Sybase System 11};PWD=test;UID=userid;DB=dbname;servername=DEV"
Dim ncon As OdbcConnection = New OdbcConnection(strconn)
Dim UafCom As OdbcDataAdapter = New OdbcDataAdapter("Select disbur_id FROM disburse where disbur_id =1234 ", ncon)
UafCom.SelectCommand.CommandType = CommandType.Text
ncon.Open()
Dim cmdbuilder As OdbcCommandBuilder = New OdbcCommandBuilder(UafCom)
UafCom.Fill(ds, "disburse")
doc.SetDataSource(ds)
Dim exportOpts As ExportOptions
exportOpts = doc.ExportOptions
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
exportOpts.DestinationOptions = New DiskFileDestinationOptions()
' Set the disk file options.
Dim diskOpts As New DiskFileDestinationOptions()
diskOpts = New DiskFileDestinationOptions()
diskOpts.DiskFileName = Server.MapPath("fin.pdf")
doc.Export()
|