Solved

Creating a crystal report from datasets

Posted on 2003-12-06
10
807 Views
Last Modified: 2013-12-25
I have a visal baisc .net application that is used by security personnel. I want to create a crystal report that uses the datasets withen the application for data. I can't get it to load the data. everytime I select to load the crystalreportpreview I get a message box for logging into the server. I would enter all the correct data, but I would get a logon error.

I then found out there is a way using the ole db interface in crystal report to link to the server. I then could connect to the server and display data, but I cannot limit the report to a specific report that needed to be printed (i.e. print the spicific (form) report that is in the database (not the crystal), but I can't figure out how to just filter what info I need). I would like to have the crystal report data come from the datasets. Is there a way to do this with out it having to connect to the server? In other words.

form1.btnprint (byval.....).handle btnprint.click
dim printform as new frprint()
dsDataset1.clear
dsDataAtapert1.fill(dsDataset1)
frprint.showdialog()

frprint has a crystal report viewer that its reportsource is crystalreport1.rpt
 
the crystalreport1.rpt would get its data from the datasets that are in the project. But I want it to do this with out asking for any type of connection string. I have the datasets filled prior to the form opening and I want the crystalreport to use these dataset for data. All the fields in the crystal report would come from the datasets.

I did notice though that when you add the dataset to the crystal report it would link to the server table that the dataset uses. I just want the data to come directly form the dataset not the server. The dataset would already have all the data from the server that it would need. Is there a way to do this? or is there a better way of doing this?

wardn
0
Comment
Question by:wardn
  • 6
  • 4
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
0
 

Author Comment

by:wardn
Comment Utility
I have already tried that and it works that is what I descriped above. It uses an ole db (ado) connection to the server. I said above that I can connect to the server database just like they use in this example. The program is not a web based type program yet. I am just creating an application that uses windows forms. I understand that I can uses tables from the database on the SQL, but I would like to use the dataset instead. That way everything is already loaded for data and the only thing it has to do is show the report. But if using the ole DB is the only way to get the data into the crystal report then is there a way to select a SQL statement for these tables being used in the crystal report using a parrameter that is given from the windowsform (i.e. "intString")? If so how. The reason I say this is because I noticed if you open the crystal report in visual basic .net, open the table, and right mouse click on a field you can select "select expert...." you can give it parramters. but if you can do this where is the stored procedure for this, because I can't find it.
 There has to be a way to use a disconnected connection and have the crystal report come off of the dataset and the data it has in it with out being connected to the Server. the reason I say this is because it would not be an availble option if it wasn't, but I don't know how to just tell the crystal report that it does not need to connect to the SQL server. Also think there should be a way is because in the windows form once the dataset is filled all the data is in the dataset that will be used.

wardn
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
That is what an ado recordset is.  Are you using ado recordsets or some other dataset?

I build all my reports based on views from the database then pass the where clause from VB

In VB using the RDC it is something like

crRpt.RecordSelectionFormula = "{view.intString} = 5"

mlmcc
0
 

Author Comment

by:wardn
Comment Utility
I am currently using a ADO Recordset, but I would like it to just use the datasets that are withen the application. I was wondering what is the purpose of the .vb side of the crystal report. I noticed that I can add SQL connections, SQLDataAdapters(that can used stored procedures), and datasets. Why can't I use the datasets that are withen the application which are filled by the SQL server (data adapters). I noticed the only way I can get data to show is to use tables under the OLE DB (ADO) which uses the microsoft jet engine for SQL Servers.
I don't understand how to use the formula section of crystal report.
I noticed that you have crRPT.recordselectionformula = "[view.intString} = 5"
How do I do this with a GUID field?

Why is it that if you use datasets it askes for a server connection when the datasets are right there within the application. I noticed that the only way you can add the datasets is through the ADO.NET Datasets. under project Data folder.
0
 

Author Comment

by:wardn
Comment Utility
If I can only control the table via giving it parameters. Is there a way using the guid as the paramter

crrpt.recordselectionformula = "{tbliradmin.id} = intGUID"
intGuid is a guid
and tbliradmin.ID is a guid field
the reason for this is because when I add the next table to the report it will go by what ever "tbliradmin.id" is equal to. I still can't figure out how to use that
recordselectfourmula
please help
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:wardn
Comment Utility
I forgot to mention that intGUID is a global variable that is given when you open the document prior to print document. the intGUID is declared in the GLOBAL.vb
0
 

Author Comment

by:wardn
Comment Utility
I found a way to get only one record to show, but I don't know how to make it dynamic.
what I did was right mouse click on the tblIRadmin.ID and then clicked "Select Expert..." What I did was select the ID field and told it to be = to a number already loaded. So now I got it to load the only record, But I don't know how to control this formula that it makes it dynamic to the "intGUID.
What I did find out using the procedure above was that if I make intGUID.ToString it helped converting it into a string, but passing it on I am still having problems. The ID field is not shown in the report. Just one of the items available on the side in the fields box.
Is there a way to pass the intGUID.ToString paramater into this field.
So now my right now my SQL statement is
Select "tblIRadmin.ReportNumber" from "tblIRAdmin" where "TblIRadmin.ID = 123124-.......'
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Try it this way
crrpt.recordselectionformula = "{tbliradmin.id} = " & cstr(intGUID)

I am not sure what you mean by datasets in VB?  Do you mean the datacontrols?

mlmcc
0
 

Author Comment

by:wardn
Comment Utility
When I try that I get an error:
"Object reference not set to an instance of an object"
It did not work still
I have even tried:
dim selectformula as string
dim selectformula1 as string = intGUID.ToString
selectformula = "{tblIRadmin.ID = " & selectformula1
crrpt.recordselectionformula = selectformula
this didn't even work.
It is not passing the info to the crystalreport. I don't know why I have followed your instructions and the instructions that are in the help section of VB.

What I mean by datasets in VB:
when you create a data adapter between the server and the application you can generate a dataset that the data will be placed into from the data adapter. the dataset is used to hold the data temporarly and the data adapter used it to store data from the server and is used to update data to the server. It is like a copy of the table in the server placed withen the application so that you do not tie up the connection spool between the application and the server.

0
 
LVL 100

Accepted Solution

by:
mlmcc earned 150 total points
Comment Utility
I don't believe you can use those unless it is an ADO recordset.

What is the full code you are using to call the report?

mlmcc
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now