locked
How To Load Data(report) In Crystal Report in VB.NET 2008 ?

    General discussion

  • Hello Friends I am new to this fourm. but My problm is very common but I didnt find any such good solution for it.

    Problm: I am working on a project in vb.net 2008 & Using Sql server 2005. all is well apart from the reporting problm. I am using crystal report 2008 for reproting in my project.

    Well I am able to load my report in report viewer by Following the steps in crystal report wizard. and it works perfectly. but guys it dosnt work in real world i mean when you are going to install ur project in another system. there will be some error in crytaal report like file path invalid. what i want to do is that........... I want to load my report in report viewer mannually means through codes. Which will work in every conditions n on every system. Like I have main problm is with my report file path name:

    my code goes like this...

    Private

     

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

    con =

    New SqlConnection(connstring)

    con.Open()

    sql =

    "Select *from Bill"

    ad =

    New SqlDataAdapter(sql, con)

    ds =

    New DataSet()

    ad.Fill(ds,

    "Bill")

     

    Dim strpath As String = Application.StartupPath + "\CrystalReport1.rpt"

     

    Dim cr As New ReportDocument

    CrystalReportViewer1.ShowRefreshButton =

    False

    CrystalReportViewer1.ShowCloseButton =

    False

    CrystalReportViewer1.ShowGroupTreeButton =

    False

    cr.SetDataSource(ds.Tables(

    "Bill"))

    cr.Load(strpath)

    CrystalReportViewer1.ReportSource = strpath

     

    End Sub

    but there is always error for invalid report file path...

    guys need urgent help as i have to compelete project very soon... or i have to go for other tools for reporting :|

    Please tell me the whole working proceedure for mannual craystal report loading in form :)

    thank you in advance

    Saturday, April 24, 2010 3:33 AM

All replies

  • :O no reply :O
    Sunday, April 25, 2010 4:34 AM
  • I'm still pretty new to crystal reports, but I'm pretty sure that the cr.load() call has to come before the cr.setdatasource() one.  move it up and I believe it will work.  Also the Fields on the CrystalReport1.rpt have to match the columns in the dataset.
    Wednesday, June 02, 2010 2:53 PM