Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
How to convert Arraylist to dataset and then set the dataset to the crystal report
. In data set i have "Total" field as extra column which will be calculated during the program execution time,also which is not in the database . How to show the total column in the crystal report...Please help me...Thank you for your precious time....
Posted 21-Nov-12 1:14am
Edited 21-Nov-12 1:15am
v2
Comments
Mohd. Mukhtar at 21-Nov-12 6:17am
   
What have you tried so for??
Bhushan Shah1988 at 21-Nov-12 6:30am
   
what is your problem?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It sounds like you need to do some research. Here are the MSDN links to the objects you are working with:
DataSet[^]
DataTable[^]
ArrayList[^]
 
First of all, a DataSet is a collection of DataTables. When you say you have a column in your DataSet, you probably really mean that you have a DataTable in your DataSet and that DataTable has the columns.
 
Now, in order to "convert" the data from your ArrayList you will have to loop through the ArrayList and add each item into the DataTable that is contained in your DataSet. You can create the loop using a For Each statement. Here is a sample (It's in VB.Net, but you should be able to get the idea and convert to C# pretty easily):
Dim myDataSet As New DataSet
Dim myDataTable As New DataTable
myDataTable.Columns.Add("Column1")
myDataSet.Tables.Add(myDataTable)
 
Dim myArrayList As New ArrayList
 
'Code that puts data into your array list would go here

'Here is the For Each loop.  It will loop through each object in the ArrayList
For Each obj As Object In myArrayList
    Dim rowNew As DataRow = myDataTable.NewRow 'Creates a new row that has the same schema as the myDataTable object
    rowNew("Column1") = obj.ToString 'Takes the object in the array list and puts it in a new row
    myDataTable.Rows.Add(rowNew) 'Adds the new row to myDataTable
Next
If you have other columns in your DataTable, you'll have to fill those as well. Also, depending upon the data type of your columns and what data you are filling your ArrayList with you may have to convert the objects in your ArrayList into the proper data type.
 
As for getting the total to appear in your crystal report, you will have to edit the report file itself to include your new field. You may have to setup groups if you want group totals or you may have to setup a page or report footer. You'll want to do some research either by google or through articles here on Code Project to research how to do that.
 
Hope this helps.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,130
1 DamithSL 5,089
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,647
4 Kornfeld Eliyahu Peter 4,409


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100