Trying to access Crystal Report thru VB.Net code?
I have a Crystal Report that I am trying to access thru my VB.Net app. My problem is that I keep getting a "Database Logon" prompt (see screenshot). My code is below and I think I might have more than I actually need. I created the report from with the VS 2008 IDE.
Code:
Private Sub rptSingleWorkOrder()
Try
strSQL = "Select A.productName, " & _
"A.productDesc, " & _
"A.startDate, " & _
"A.endDate, " & _
"A.totalCost, " & _
"A.laborRate, " & _
"A.wrkID, " & _
"B.componentName, " & _
"B.reqdPieces, " & _
"B.totalCost, " & _
"B.specialInstruction, " & _
"B.imageLocation " & _
"From tblWorkOrderMst A INNER JOIN tblWorkOrderDet B ON " & _
"A.wrkID = B.wrkID " & _
"Where A.wrkID = '" & mWOID & "'"
Dim cr As New rptWorkOrder
Dim sel As New SqlCommand(strSQL, cnn)
DA.SelectCommand = sel
DA.Fill(DS)
cr.RecordSelectionFormula = "{tblWorkOrderMst.wrkID} = '" & mWOID & "'"
For i = 0 To cr.Database.Tables.Count - 1
cr.Database.Tables(i).ApplyLogOnInfo(ConInfo)
Next
cr.SetDataSource(DS.Tables(0, 1))
crViewer.DisplayGroupTree = False
crViewer.ShowGroupTreeButton = False
crViewer.ReportSource = cr
Catch ex As Exception
Messagebox.Show(ex.Message)
End Try
End Sub
By the way, this code runs cleanly completely thru from the time the procedure is called until it exits.
Thanks,
Re: Trying to access Crystal Report thru VB.Net code?
Hi.Being ages with using Crystal reports but is cnn a global value?Check to see it has the correct connections.
Re: Trying to access Crystal Report thru VB.Net code?
Yes..."cnn" is a global variable...
Re: Trying to access Crystal Report thru VB.Net code?
Hey.
Again out of the top of my mind, and sorry if it's wrong.
I remember a variable you set on Crystal that will deactivate the logon screen, or something like that.Sorry if i'm wrong but i see noone helped you so...
Re: Trying to access Crystal Report thru VB.Net code?
If there is a variable or property within CR, I have no idea what it could be.