Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Array List to Parameter in Crystal Reports

Status
Not open for further replies.

kvang

Programmer
Oct 7, 2005
129
US
I am storing a list of items in an array. Can I display the items in the array list in Crystal Reports by passing it to a parameter?
 
Maybe. CR can take an array value as a parameter, but I think it can only handle arrays of primative types (char, String, date, int, decimal, etc...)

Another option would be to create a datatable with the information you want to use in crystal, and then to pass that datatable into crystal.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I have a two-dimensional array. How can I pass it a parameter so that it would display every item on the crystal report? Code examples would be helpful. Thanks.
 
Instead of using a 2-d array, use a datatable, then pass the datatable to CR (or save the datatable to XML and have CR read the XML file) as a data source.

I don't have any code samples of this handy (all of my stuff is wrapped up in abstraction, it wouldn't make sence with out a lot of extra supporting code), but you can google for: passing datatable to crystal reports

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
The reason why I am using an array instead of a datasource is because the items I need to display are coming from an Oracle table and SQL table. So I retrieved items from the Oracle table, store it in an array and retrieved items from the SQL table and store it in the same array but in a different column. They are related by unique ID, but come from different database.

Is it possible to just pass the items in the array to a parameter and display on the CR?
 
I do not know if CR can handle multi-dimensional arrays, nor how you could display each item.

What you can do, is store that info in an unbound datatable.
Code:
dim dt as new datatable("MyTableName")
dt.columns.add("Column1",gettype(string))
dt.columns.add("Column2",gettype(integer))

dim dr as datarow
dim i as integer
for i = 0 to SomeCountMax
  dr = dt.newrow
  dr.items("Column1") = SomeValueBasedOnI
  dr.items("Column2") = SomeValueBasedOnI
  dt.rows.add(dr)
next i

Once you have the datatable populated you can pass it into CR and use it as a datasource.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Can I set the datasource to CR like this?

Code:
Dim CR As New MyCrystalReport

CR.SetDataSource(dt)

 
Something like that. I haven't worked with sending datasets to CR in quite a while. My current system uses XML files. I use the Dataset.WriteXML(filename) method to save the data to an XML file then I set up CR to read from the XML file. But I know that it is possible to send a dataset straight to CR.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thank you. Your suggestions and tips have been very helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top