Okay, figured out the file part. Here's the code in case anyone needs it. I'm going to post more than just the export (to pdf) portion as I know there are also issues with Crystal prompting for username/password when opening the DataSet. I am not having that issue with this code. Hopefully I can save someone the time I have spent on this. This uses the a strongly typed DataSet...I believe they call this the "push" method.
Now All I need to do is figure out how to format the report so it looks nice
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Reporting
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Dim doc As New ReportDocument
Public Sub CreatePDF(ByVal formid As String)
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New MyDataSet() 'The DataSet you created.
' Workaround for strongly typed method not working
Dim fileName As String = Server.MapPath("CrystalReport.rpt")
doc.Load(fileName)
Try
myConnection = New SqlConnection("Data Source=server;Initial Catalog=DB;Persist Security Info=True;User ID=userid;Password=pass")
MyCommand.Connection = myConnection
MyCommand.CommandText = "SELECT * FROM Table WHERE (FormID = @formid)"
MyCommand.Parameters.Add(New SqlParameter("@formid", formid))
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "MyDataTable")
doc.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = doc
CrystalReportViewer1.Visible = False
Catch Ex As Exception
End Try
End Sub
Protected Sub btnConvert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnConvert.Click
Try
Dim ExpOptions As ExportOptions
Dim DiskFileDestOpts As New DiskFileDestinationOptions
Dim FormatTypeOpts As New PdfRtfWordFormatOptions
DiskFileDestOpts.DiskFileName = "D:\Temp\Test.pdf"
ExpOptions = doc.ExportOptions
With ExpOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = DiskFileDestOpts
.FormatOptions = FormatTypeOpts
End With
doc.Export()
Catch Ex As Exception
MsgBox(Ex.ToString)
End Try
End Sub