CR report connStr

S

sloan

Dim connectionStrings As ConnectionStringSettingsCollection =
ConfigurationManager.ConnectionStrings

Dim connection As ConnectionStringSettings
For Each connection In connectionStrings



Dim connectionStringName As String = connection.Name
Dim connectionString As String = connection.ConnectionString
Dim providerName As String = connection.ProviderName

Debug.Print(connectionStringName)
Next connection
 
S

sloan

You're missing the point.


// set report's dataset
report.SetDataSource(ds);

You give it an already populated dataset.

the CR should NOT know anything about a db connection string.


You need to write some kind of code to populate the dataset.
 
P

Paulo Roberto

sloan, thanks the help...

I designed a CR report from wizard and I had to set a database connection to
make the report: groups, displayed fields, tests, etc. when I click Preview
Report it shows fine... beautiful... but how will I deploy on the server ? I
have to pass the sql server connstr from web.config...

Im using the code: report.SetDataSource(ds); but the aspx shows me a default
box form to fill the properties like database, userid, pwd, etc... maybe Im
not setting some property, something like that... what do you think ?

About deploying I need to copy the CR dlls to the bin folder?

thanks man!
 
S

shh

http://www.codeproject.com/useritems/CreatingCrystalReports.asp

Follow the instructions at the link. Which involved creating a
dataset, before working with CR.

What you describe below is the "pull", because you're adding
connection strings, select queries, etc, etc.

This is the exact thing I said is a dangerous slope.

Go through the instructions (at the link), and don't just download
the code and run it.
Go through the directions yourself.
 
P

Paulo Roberto

Thanks sloan, but on the article I see that was created a .xsd schema...
must it be created just to design the CR (fields, sqls, grouping, etc...)?

and what is: myDataReport myDataReport = new myDataReport();

myDataReport is a class? how can it be accessed?

thanks again man!
 
S

sloan

The xsd provides two things.

First, the thing to design the report off of.
Second, the thing to put the data into (in a specfic format).

Whenever you create a report , you call it something.

EmployeeByDepartmentReport (.rpt). This becomes a real "object", that you
can instantiate.

So if you did a "Add New Item", "Crystal Report", and named it
"EmployeeByDepartmentReport" (.rpt), then you'll have this code.

EmployeeByDepartmentReport empDeptRpt = new EmployeeByDepartmentReport ();
// as in myDataReport myDataReport = new myDataReport();


Here is another walk thru, from Crystal Reports itself:

http://resources.businessobjects.co...rd&dnlPath=rtm_reportingoffadonetdatasets.pdf


The most important lines of that KB are:



EmployeeByDepartmentReport empDeptRpt = new EmployeeByDepartmentReport();


EmployeeDS ds = SomeMethodYouCreateToMakeAnEmployeeDS();



/* Use Report Engine object model to pass populated dataset
to report */
empDeptRpt.SetDataSource (ds);



//CrystalReportViewer1 is the CR Viewer you "drag" onto the webform
/* bind report object with data to the Web Forms Viewer */
CrystalReportViewer1.ReportSource = empDeptRpt;



YOU STILL NEED TO LOOK AT THE KB and go through it, do not rely upon my code
(immediatly above).
I am just pointing out the important aspects/lines of the code.
 
P

Paulo

thanks, but when I rename the rpt file does not show as you said:
EmployeeByDepartmentReport empDeptRpt = new EmployeeByDepartmentReport ();

the CR article tells us to type: "public CustomerSales oRpt = null" wich
CustomerSales is the name of file, but when hit Ctrl+F5 the VS stops: "The
type or namespace could not be found"...

What can be the problem?

thanks sloan!
 
S

sloan

You don't rename the file

//but when I rename the rpt file //end quote

.........

When you add the file, it gets added as Something.rpt (I think that's the
extension)

but somewhere (under the covers), there is an object of that name.


I'd start with the KB on how to do it, and work up from there, instead of
taking your already existing report.

Learn the fundamentals with the KB example, when move up from there.
 
S

sloan

Now you know why I don't lilke CR.

You think the PUSH method has quirks, the PULL method has even more "screw
you" quirks.

I don't know what the best solution is.

My advice is:
1. Always use a strongly typed dataset.
2. Build the report against the DataSet (or use the XSD schema option)
3. Prepopulate the DataSet
4. Send that to your instantiated MyReportObject (and the viewer).

That's all I got dude.

Here is the saving grace.
Once you get it to work ... this way... if you ever get tired of CR, you can
switch to another reporting method
Active Reports
Good ole' asp:repeaters

And you don't have to re-invent the wheel.

You've discovered 2 things.
What PUSH vs PULL is.
CR has quirks. I started with CR when it came with VB4. I hate CR.
But sometimes the job forces you to use it.

Good luck.
 
P

Paulo

sloan, I made one report using a defined connection on the designer CR mode
and worked very well... CR is not so bad (I think)...
I am trying efforts just to pass the connection string, dataset to it...
I will keep my search to solve the problem!

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top