Crystal Report error on calling it from .Net Code.

I am calling Crystal Report from .Net Application. Existing Report works great. However, i did some changes on the crystal Report.
 It throws exception.  Report is stored as tiff Image file with Barcode on it.

I presume issue is in the .net Dataset.I have attached Error Screen Shot as well.

Dim RptCon As New Data.SqlClient.SqlConnection(ConString)
        Dim RptCmd As New Data.SqlClient.SqlCommand("MYStoredProc", RptCon)
        RptCmd.CommandType = Data.CommandType.StoredProcedure

        'Add docid as a parameter
        RptCmd.Parameters.Add("@DocID", Data.SqlDbType.VarChar, 9)
        RptCmd.Parameters("@DocID").Value = lDocID

        'Create adapter and dataset to hold report contents data returned by the proc
        Dim RptAdapter As New Data.SqlClient.SqlDataAdapter(RptCmd)
        Dim RptDS As New System.Data.DataSet

        'Execute proc and place report data in dataset

        Dim ReportViewer1 As New Microsoft.Reporting.WebForms.ReportViewer

        Dim RptDataSource As New Microsoft.Reporting.WebForms.ReportDataSource("MyDataSet", RptDS.Tables(0))
        ReportViewer1.LocalReport.ReportEmbeddedResource = "ReportFile.rdlc"

        'Set the datasource of the invisible rpeort viewer embeded in this form to the data we've just obtained
        'and refresh the reportviewer

        'Initialize required parameter variables for rendering newly-created report as a tif
        Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
        Dim streamids As String() = Nothing
        Dim mimeType As String = Nothing
        Dim encoding As String = Nothing
        Dim extension As String = Nothing
        Dim deviceInfo As String
        Dim bytes As Byte()

        ' Chokka - Image is not created. Bytes  - Failing.

        'The deviceinfo parameter specifies the settings used to render the report as an image
        'X and Y resolution should be specified, as well as output format of Tif
        deviceInfo = "<DeviceInfo><DpiX>200</DpiX><DpiY>200</DpiY><OutputFormat>TIFF</OutputFormat></DeviceInfo>"

        'Render the report as image to a local bytes variable
        bytes = ReportViewer1.LocalReport.Render("Image", deviceInfo, _
          mimeType, encoding, extension, streamids, warnings)

        'Use a filestream to place the report file from the bytes variable into the target
        'report output file (the path being specified by the report generation sproc above)
        Dim fs As New System.IO.FileStream(OutputFI.FullName, IO.FileMode.Create)
        fs.Write(bytes, 0, bytes.Length)

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The message seems to indicate you didn't supply a dataset to the report.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chokkaStudentAuthor Commented:
Thanks mlmcc

This is an existing code .. populating existing report which was working fine.

Dim RptDataSource As New Microsoft.Reporting.WebForms.ReportDataSource("MyDataSet", RptDS.Tables(0))
        ReportViewer1.LocalReport.ReportEmbeddedResource = "ReportFile.rdlc"

Open in new window

What i did was .. I have to add new columns / fields to the report and tried to rebind the report to the code.

I can see the dataset is populated with data. But not sure, Dataset is not mapping or linking to the report. Couldn't figure it out
You probably need to have the report do a VERIFY DATABASE to pickup the new fields.

Not sure how you do that in the .NET version of Crystal.

In the standalone, it is under the DATABASE menu

chokkaStudentAuthor Commented:
Visual Studio Environment .. Menu - Report - Has option to add or remove DataSet.

After i removed all unwanted DataSet, Report is working fine.

chokkaStudentAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.