locked
VBNET2008 CrystalReport DateSet1 RRS feed

  • Question

  • Hullo Friends,

    I need your help and please help me.

    I been requested to use VBNET2008  to develop an application to generate Crystal Report. I was told to use Crystal Report Dataset1 to be fill with data from normal Dataset using SQL String to retrieve data from SQL SERVER 200

    I have not done it before and wondering to report the data on Crystal Report using the DataSet1 and also how to fill the CrystalReport DataSet1 with data from normal Dataset

    Please share with me the coding and I am very interested in learning it logically by viewing the logical coding.

    Thank You Friends for helping me.

    Have A Good Day,

    Cheers,

    Lennie


    Thank you very Much, Have a Good Day. Cheers, Lennie
    • Moved by edhickey Monday, July 11, 2011 2:29 PM (From:.NET 3.0/3.5 Windows Workflow Foundation)
    Monday, July 11, 2011 6:43 AM

Answers

  • Hello,

    CR 9 was never supported in VS 2008, it's only supported in VS 2002 and VS 2003. Meaning we've never tested the full version of CR 9 in VS 2008.

    Anyways, you've never actually confirmed you have tried anything, sample app's or the code from the links? If you have what error are you getting and what is the code you are using?

    Don


    Don Williams
    Thursday, July 14, 2011 2:15 PM
  • Hullo SapDon,

    Thank you for sharing information with me. Yes, you are right that I did not embedded my coding.

    Here are the error message:  DataTable1 Error Message : Object reference not set to an instance of an object

    Sofrware used are VbNET2008 and Crystal Report Ver 9.

     

    And here are the overall coding:

        Private Sub btnCrystal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCrystal.Click

     

            'retrieve data using SQL and fill Crystal Report DataSet1.xsd using normal DataSet

          

            Try

                Dim DS as Dataset = New System.Data.DataSet     ' < -- Normal dataset

                Dim DataTable1 as DataTable  = New DataTable

                Dim cryDS1 as DataSet1 = New DataSet1        ' < - - Crystal Dataset1

     

                Dim strsql As String = Nothing

                strsql = "Select OrderID, "

                strsql &= "Convert(Varchar(10), OrderDate, 103) as [OrderDate], "

                strsql &= "ProductName,"

                strsql &= “ From  CustomerInvoice “  

                strsql &= "Order by OrderID, OrderDate "

     

                sqlconn = New SqlConnection(connstr)

                sqlconn.Open()

                DA = New SqlDataAdapter(strsql, sqlconn)

     

                DA.Fill(DS, "Invoice")

                cryDS1.Clear()

                cryDS1.Tables(0).Clear()

                sqlconn.Close()

     

                Dim cryDS1Row As DataRow = cryDS1.Tables(0).NewRow

           

                For Each Row As DataRow In DS.Tables("Invoice").Rows

                   cryDS1Row("OrderID") = CType(Row("OrderID"), String)

                   cryDS1Row("OrderDate") = CType(Row("OrderDate"), String)

                   cryDS1Row("ProductName") = CType(Row("ProductName"), String)       

     

                    cryDS1.Tables(0).Rows.Add(cryDS1Row)

                    cryDS1Row = Nothing

                    cryDS1Row = cryDS1.Tables(0).NewRow

                  Next

     

                ' -----------------------------------------------------------------------

                ' declare object for CrysalReportTest.rpt report

                Dim objRpt As New CrystalReportTest

                Dim cryFolder As String = "F:\VBNet2008Practice\CrystalReportTest.rpt"

     

                objRpt.Load(cryFolder)

                objRpt.SetDataSource(cryDS1.Tables(0))

                Me.CrystalReportViewer1.ReportSource = objRpt

                Me.CrystalReportViewer1.Refresh()

     

                cryDS1.Clear()

     

            Catch ex As Exception

                MessageBox.Show(ex.Message)

            End Try

     

        End Sub

     

    Thank you for trying to help me. appreciate you very much.

    Based on your shared coding based on mine above, I will post the overall working coding here to share it with other Newbies who are using the same Software and Crystal report.

     

    Have A Good Day,

    Cheers,

    Lennie

     


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Friday, July 15, 2011 10:46 PM

All replies

  • Hi Tee,

    Search this forum on "SetDataSource" and you'll find lots of sample code on how to .

    Don


    Don Williams
    Monday, July 11, 2011 9:38 PM
  • Hi Don William, Thank you for trying to help me. Appreciate that very much. You are awesome and womderful. Can you please share with me the URL Link for your suggestion of using setdatasouce option. I am very interested in it. Thank You, Cheers, Lennie
    Thank you very Much, Have a Good Day. Cheers, Lennie
    Monday, July 11, 2011 11:39 PM
  • Tuesday, July 12, 2011 12:15 AM
  • Try this one: http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/98760ae9-3bfb-4ac2-bcb0-ebe4305067bf/

    And need more info, version of VS and CR and windows or web app?

    Don


    Don Williams
    Tuesday, July 12, 2011 2:52 PM
  • Hi Hardz,

    Thanks you for trying to help me. Appreciate that very much.

    You are awesome and wonderful.

    I am very sorry that I did logged into the URL link that you provided and it did not help me.

    Thank You,

    Cheers,

    Lennie


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Wednesday, July 13, 2011 12:07 AM
  • Hi Sap Don,

    Thanks to you for trying to me help. I did view the URL Link that you share with me and I am very surprised that it not meet request. Appreciate your help very much.

    I am using VBNET2008, CrystalReport Ver.9 and using both for Window application.

    Thank You.

    Cheers,

    Lennie

     


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Wednesday, July 13, 2011 12:10 AM
  • Hi Lennie,

    VB should come with Crystal Reports Basic Version 10.5 so you may want to use those assemblies rather than CR 9.

    You can also find lots of samples here: http://wiki.sdn.sap.com/wiki/display/BOBJ/Crystal+Reports+SDK+Sample+Applications

    Thank you

    Don


    Don Williams
    Wednesday, July 13, 2011 9:52 PM
  • Hi SAPDON,

    I appreciate your suggestion of using an upgrade  version of Crystal Report.

    I have to use whatever is available in the company that I am working for. Crystal Report Version 9 is the main version and VBNET2008 is the main and standard software within the company as well.

    I have to follow the IT Manager instructions otherwise he will made me redundant as he has done that to my new programmer friend who insist of using C#NET instead of VBNET2008

    Thank you anyway for trying to help me. You are wonderful and awesome,

    Cheers,

    Lennie

     


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Wednesday, July 13, 2011 11:35 PM
  • Hello,

    CR 9 was never supported in VS 2008, it's only supported in VS 2002 and VS 2003. Meaning we've never tested the full version of CR 9 in VS 2008.

    Anyways, you've never actually confirmed you have tried anything, sample app's or the code from the links? If you have what error are you getting and what is the code you are using?

    Don


    Don Williams
    Thursday, July 14, 2011 2:15 PM
  • Hullo SapDon,

    Thank you for sharing information with me. Yes, you are right that I did not embedded my coding.

    Here are the error message:  DataTable1 Error Message : Object reference not set to an instance of an object

    Sofrware used are VbNET2008 and Crystal Report Ver 9.

     

    And here are the overall coding:

        Private Sub btnCrystal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCrystal.Click

     

            'retrieve data using SQL and fill Crystal Report DataSet1.xsd using normal DataSet

          

            Try

                Dim DS as Dataset = New System.Data.DataSet     ' < -- Normal dataset

                Dim DataTable1 as DataTable  = New DataTable

                Dim cryDS1 as DataSet1 = New DataSet1        ' < - - Crystal Dataset1

     

                Dim strsql As String = Nothing

                strsql = "Select OrderID, "

                strsql &= "Convert(Varchar(10), OrderDate, 103) as [OrderDate], "

                strsql &= "ProductName,"

                strsql &= “ From  CustomerInvoice “  

                strsql &= "Order by OrderID, OrderDate "

     

                sqlconn = New SqlConnection(connstr)

                sqlconn.Open()

                DA = New SqlDataAdapter(strsql, sqlconn)

     

                DA.Fill(DS, "Invoice")

                cryDS1.Clear()

                cryDS1.Tables(0).Clear()

                sqlconn.Close()

     

                Dim cryDS1Row As DataRow = cryDS1.Tables(0).NewRow

           

                For Each Row As DataRow In DS.Tables("Invoice").Rows

                   cryDS1Row("OrderID") = CType(Row("OrderID"), String)

                   cryDS1Row("OrderDate") = CType(Row("OrderDate"), String)

                   cryDS1Row("ProductName") = CType(Row("ProductName"), String)       

     

                    cryDS1.Tables(0).Rows.Add(cryDS1Row)

                    cryDS1Row = Nothing

                    cryDS1Row = cryDS1.Tables(0).NewRow

                  Next

     

                ' -----------------------------------------------------------------------

                ' declare object for CrysalReportTest.rpt report

                Dim objRpt As New CrystalReportTest

                Dim cryFolder As String = "F:\VBNet2008Practice\CrystalReportTest.rpt"

     

                objRpt.Load(cryFolder)

                objRpt.SetDataSource(cryDS1.Tables(0))

                Me.CrystalReportViewer1.ReportSource = objRpt

                Me.CrystalReportViewer1.Refresh()

     

                cryDS1.Clear()

     

            Catch ex As Exception

                MessageBox.Show(ex.Message)

            End Try

     

        End Sub

     

    Thank you for trying to help me. appreciate you very much.

    Based on your shared coding based on mine above, I will post the overall working coding here to share it with other Newbies who are using the same Software and Crystal report.

     

    Have A Good Day,

    Cheers,

    Lennie

     


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Friday, July 15, 2011 10:46 PM
  • Hi Tee,

    Thank you for sharing your entire code snippet here for other friends' reference.

    Have a nice week.
    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 18, 2011 3:39 AM
    Moderator