Results 1 to 4 of 4

Thread: How to use crystal report with VB.NET by passing the SQL statement?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2010
    Posts
    2

    How to use crystal report with VB.NET by passing the SQL statement?

    How to use crystal report with VB.NET by passing the SQL statement?
    Try to pass sql statement to a crystal report in vb.net 2008 after creating a dataset with it yet it will load the report but not showing the records, plsss help

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to use crystal report with VB.NET by passing the SQL statement?

    Welcome to the forums.

    Show us what you are doing, code wise, that isn't working.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,421

    Re: How to use crystal report with VB.NET by passing the SQL statement?

    have a look at the dynamic crystal reports link in my signature

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2010
    Posts
    2

    Re: How to use crystal report with VB.NET by passing the SQL statement?

    I try to pass sql statement to a crystal report in vb.net 2008 after creating a dataset and added it to the crystal report as datacolumn with it yet it will load the report but not showing the records, pls help

    ' The Code on theform with button and crystal reportviewer
    Public Class Form1

    Dim objRpt As New ReportDocument
    'Dim objRpt As New CrystalReportsException
    'select staffid,surname,othernames,deptcode from stafftab imagepath Dim img As String = My.Settings.imagepath

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Using CCNN As New SqlConnection(My.Settings.bConn)
    Dim sql As String

    sql = "select staffid as Column1,surname as Column2,othernames as Column3,deptcode as Column4 from stafftab"

    Dim dscmd As New SqlDataAdapter(sql, CCNN)
    CCNN.Open()
    Dim ds As New DataSet1
    dscmd.Fill(ds, "stafftab")
    objRpt.Load("Crstafflst.rpt")
    objRpt.SetDataSource(ds.Tables(1))
    CrystalReportViewer1.ReportSource = objRpt
    CrystalReportViewer1.Refresh()
    End Using
    End Sub


    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim rptpathh As String = My.Settings.rptpath
    Dim sDir As String = Directory.GetDirectoryRoot(Directory.Get… 3)
    Dim sCurDir As String = Directory.GetCurrentDirectory.Substring(… 3) + rptpathh
    Directory.SetCurrentDirectory(sCurDir)
    Dim MDIParent1 As New MDIParent1
    Me.MdiParent = MDIParent1.MdiParent
    CrystalReportViewer1.RefreshReport()

    End Sub

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