Results 1 to 5 of 5

Thread: Trying to access Crystal Report thru VB.Net code?

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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,
    Last edited by blakemckenna; Sep 6th, 2010 at 06:47 PM.
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width