Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert a dataset to Crystal Reports (Shows only the first row in dataset)

Posted on 2004-08-12
7
Medium Priority
?
552 Views
Last Modified: 2010-05-18
Hello..

I want insert an array to crysstal reports, or a dataset.. but the array or dataset
i will "make mySelf".. not directly from a database.. how do i do that..

so how do i create the array or dataset and insert it to Crystal reports.
I want the same effect that a dataset has, that was created from a database
and then inserted to CR.

1. Get data from my database.
2. calculate the values i want to insert to CR from the dataset
3. Create a new dataset or an array.
4. Insert the new dataset or array to CR

i have this code for now.. the dataset seems to work... i have tested to pass the dataset
to a datagrid and it woks.. i have made an xsd file


my problem is that Crystal reports only shows the first row of my dataset..



this is the code i use for creating a datset


Private Function CreateCustomDataSet() As DataSet
        ' create a dataset object
        Dim oDataSet As DataSet
        oDataSet = New DataSet
        '
        ' create a data table object
        Dim oDataTable As DataTable
        oDataTable = New DataTable("T2")
        '
        ' we need a type object to specify the column
        ' data type
        Dim oType As Type
        Dim oDataColumn As DataColumn
        '
        ' create a type object for required datatype
        oType = System.Type.GetType("System.String")
        ' create a new column in the table structure
        oDataColumn = New DataColumn("PersonKey", oType)
        ' add the column in the table object
        oDataTable.Columns.Add(oDataColumn)
        '
        ' add one more column
        oType = System.Type.GetType("System.String")
        oDataColumn = New DataColumn("PersonName", oType)
        oDataTable.Columns.Add(oDataColumn)
        '
        ' onemore column
        oType = System.Type.GetType("System.String")
        oDataColumn = New DataColumn("Address", oType)
        oDataTable.Columns.Add(oDataColumn)
        '
        ' one more column
        oType = System.Type.GetType("System.Int16")
        oDataColumn = New DataColumn("Age", oType)
        oDataTable.Columns.Add(oDataColumn)
        '
        ' now add the completly prepared table to the dataset
        oDataSet.Tables.Add(oDataTable)
        '
        ' now we are ready to fill the dataset with data
        Dim oDataRow As DataRow
        '
        ' get a new datarow from the table object
        ' the dataset knows what fields to create as we are asking
        ' the exact table about that row
        oDataRow = oDataSet.Tables("T2").NewRow
        ' fill required data
        With oDataRow
            .Item("PersonKey") = "AB12"
            .Item("PersonName") = "Ramesh"
            .Item("Address") = "Delhi"
            .Item("Age") = 34
            ' now add the row in the datatable
            oDataSet.Tables("T2").Rows.Add(oDataRow)
        End With
        '
        ' can add as many rows as you can
        oDataRow = oDataSet.Tables("T2").NewRow
        With oDataRow
            .Item("PersonKey") = "AB13"
            .Item("PersonName") = "Seema"
            .Item("Address") = "Bareli"
            .Item("Age") = 25
            oDataSet.Tables("T2").Rows.Add(oDataRow)
        End With
        '
        ' now we can use this dataset anywhere a DataSet is expected
        Return oDataSet
        '
    End Function



this code for inserting the data into CR


 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim Ds As DataSet
        Ds = New DataSet
        Ds = CreateCustomDataSet()

        Dim rpt As New cr
        rpt.SetDataSource(Ds)
        CrystalReportViewer1.ReportSource = rpt
        DataGrid1.DataSource = Ds.Tables(0)

    End Sub

i
But only the first row will show in CR..

i have design the report as i want  by dragging and dropping these fields. i got from xsd, but when i drop the filed
in CR on the filed will show.. not the name in the section above.. i don't know if that has anyting with my problem.
but someting is from..


here is the xml code for the xsd file..

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Dataset1" targetNamespace="http://tempuri.org/Dataset1.xsd" elementFormDefault="qualified"
      attributeFormDefault="qualified" xmlns="http://tempuri.org/Dataset1.xsd" xmlns:mstns="http://tempuri.org/Dataset1.xsd"
      xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
      <xs:element name="Dataset1" msdata:IsDataSet="true">
            <xs:complexType>
                  <xs:choice maxOccurs="unbounded">
                        <xs:element name="T2">
                              <xs:complexType>
                                    <xs:sequence>
            <xs:element name="PersonKey" msdata:AutoIncrement="true" type="xs:string" minOccurs="0" />
                  <xs:element name="PersonName" type="xs:string" minOccurs="0" />
                  <xs:element name="Address" type="xs:string" minOccurs="0" />
                        <xs:element name="Age" type="xs:integer" minOccurs="0" />
                                    </xs:sequence>
                              </xs:complexType>
                        </xs:element>
                  </xs:choice>
            </xs:complexType>
            <xs:key name="Dataset1Key1" msdata:PrimaryKey="true">
                  <xs:selector xpath=".//mstns:T2" />
                  <xs:field xpath="mstns:PersonKey" />
            </xs:key>
      </xs:element>
</xs:schema>
0
Comment
Question by:NissePPP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 4

Expert Comment

by:srcalc
ID: 11784900
Why don't you send just the datatable?

rpt.SetDataSource(oDataTable)
0
 
LVL 1

Author Comment

by:NissePPP
ID: 11787979
hmm but don't i need to send the dataset.. becuse i use xsd files for CR
0
 
LVL 1

Author Comment

by:NissePPP
ID: 11889874
hmm i solved the problem.. i need to use "Expert wizard" when creating a report.. not use a bland report as i did before..

then i will work...

 hmm i want my ponits back :).

. how do i do that.. :)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:NissePPP
ID: 11890654
post something.. so i can give you the points
0
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 800 total points
ID: 11890666
yes!
0
 
LVL 1

Author Comment

by:NissePPP
ID: 11890676
fixed.. :)


thx m8.. very nice work... ;)
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11890691
np love doing this sh*t
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question