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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How generate a Crystal Report in runtime???

Status
Not open for further replies.

dcampo

Programmer
Jun 13, 2006
71
EC
Hi everyone

Sorry I don't write very well the english!!!

I checked in this forum how generate and change the content a crystal report in runtime...

I'm using C# 2005 and Crystal Report version 10, both from Visual Studio 2005.

For change the content the Crystal Report, it's using a DataSet but I have problems...

View my code (in the event Page_load)

string infcon, sql;
infcon = "User=sa; Pwd=salesiana; Database=celular";
sql = "Select cat_marca, cat_modelo From dbcel_catalogo Where cat_codigo='9'";
SqlDataAdapter adapter = new SqlDataAdapter(sql, infcon);
DataSet dataset = new DataSet();
adapter.Fill(dataset, "celular");
ReportDocument rp1 = new ReportDocument();
rp1.SetDataSource(dataset);
CrystalReportViewer1.ReportSource = rp1;

Any help me!!!

please.

thanks.
 
I think if you want to create the report dynamically, you will have to create the fields on the report as well. Not sure why you want to do this, as it will be complicated. I would create the report in the designer first.
The report won't just show your results with:
CrystalReportViewer1.ReportSource = rp1;
That would work for a gridview, but not a CR.
 
thanks jbenson001 for response.

Why I want to do this??

In my database, i have many fields from a table, depending so users login session, the crystal report only should show that information for unique user. That's the same Crystal Report, only change 2 fields depending the users.

help me...

What would I do first?

thanks
 
You can show or hide the report fields depending on the user. Create the report in the designer to show all fields, then on the load of the report, check the user and hide the fields as necessary. There are many examples on line and on
Jim
 
Ok but I'd want to generate the Crystal Report in runtime, is possible?

How would it is the code?

thanks
 
I'd want to generate the crystal report using a DataSet, the crystal report should be created??

How can I to do this?


thanks
 
dynamic creation will be very tedious .. I would use the designer.. you can use your dataset you have created
 
ok...

How can I to do this?

When I generate a DataGrid using the wizard, I can modify the sentece SQL for use parameters.

Now, when I generate a Crystal Report using the wizard, Where Can I modify the sentence for use parameters (for example: the content from: [QueryString], Control... )

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top