Results 1 to 5 of 5

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

  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

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

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

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

    Yes..."cnn" is a global variable...
    Blake

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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...
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

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

    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.
    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