dotNET Dev

hey guys,

I hang on one issue since last two weeks. I have VB 2005 Express edition and crystal report XI 2. When i try to open external crystal report file using VB 2005 but it shows error as "Specified cast is not valid."

This code is under button_click event.

I tried to search on site but couldn't find solutions over this.

My code as follows:

Dim CR As New ReportDocument()

CR.Load(Application.startuppath & "\Reports\Widal.rpt")

Dim pvName As New ParameterValues

Dim pvDoc As New ParameterValues

Dim pvDate As New ParameterValues

Dim p1 As New ParameterDiscreteValue

Dim p2 As New ParameterDiscreteValue

Dim p3 As New ParameterDiscreteValue

Try

p1.Value = cboDoctor.SelectedValue

pvName.Add(p1)

CR.DataDefinition.ParameterFields("PatName").ApplyCurrentValues(pvName)

p2.Value = "ABC"

pvDoc.Add(p2)

CR.DataDefinition.ParameterFields("DocName").ApplyCurrentValues(pvDoc)

p3.Value = "09/01/2007"

pvDate.Add(p3)

CR.DataDefinition.ParameterFields("TestDate").ApplyCurrentValues(pvDate)

CRViewer1.ReportSource = CR <-------Error Shows here.

Catch ex As Exception

MsgBox(ex.Message.ToString())

End Try

So, what problem could be there

Any help would be greatly appreciated.



Re: Visual Basic Express Edition Specified cast is not valid.

dotNET Dev

Pls Help. It is urgent.





Re: Visual Basic Express Edition Specified cast is not valid.


Re: Visual Basic Express Edition Specified cast is not valid.

dotNET Dev

Hi Andreas,

I tried it but didn't find solutions. What is the problem on that line for Reportsource

Pls. Reply...





Re: Visual Basic Express Edition Specified cast is not valid.

Bruno Yu - MSFT

dotNET Dev,

Try to change the error statement into CRView1.ReportSource=CR.Load

Actually, you can dim myReportSource = path as your ReportSource, take a look at the following article on Binding to ReprotSource:

http://msdn2.microsoft.com/en-us/library/ms227542(VS.80).aspx






Re: Visual Basic Express Edition Specified cast is not valid.

dotNET Dev

BrunoYu

Thanks for your reply...

I didn't get namespace of  CrystalDecisions.Enterprise

but i have  CrystalDecisions.ReportSource. I tried it but didnt get class of ReportSource in that namespace.

waiting for reply...