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

Posted on 2004-08-12
Last Modified: 2010-05-18

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
        ' add one more column
        oType = System.Type.GetType("System.String")
        oDataColumn = New DataColumn("PersonName", oType)
        ' onemore column
        oType = System.Type.GetType("System.String")
        oDataColumn = New DataColumn("Address", oType)
        ' one more column
        oType = System.Type.GetType("System.Int16")
        oDataColumn = New DataColumn("Age", oType)
        ' now add the completly prepared table to the dataset
        ' 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
        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
        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
        CrystalReportViewer1.ReportSource = rpt
        DataGrid1.DataSource = Ds.Tables(0)

    End Sub

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="" elementFormDefault="qualified"
      attributeFormDefault="qualified" xmlns="" xmlns:mstns=""
      xmlns:xs="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
      <xs:element name="Dataset1" msdata:IsDataSet="true">
                  <xs:choice maxOccurs="unbounded">
                        <xs:element name="T2">
            <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:key name="Dataset1Key1" msdata:PrimaryKey="true">
                  <xs:selector xpath=".//mstns:T2" />
                  <xs:field xpath="mstns:PersonKey" />
Question by:NissePPP
  • 4
  • 2

Expert Comment

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


Author Comment

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

Author Comment

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.. :)
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Author Comment

ID: 11890654
post something.. so i can give you the points

Accepted Solution

Daniellus83 earned 200 total points
ID: 11890666

Author Comment

ID: 11890676
fixed.. :)

thx m8.. very nice work... ;)

Expert Comment

ID: 11890691
np love doing this sh*t

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net Report Printing Issue 3 54
Store results in 3 24
Footer for each row on Gridview 2 32 -  GroupBox / Panel DataBinding and behavior 3 13
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

856 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