hi,
I have a db and i want to print reports from that.. can u please guide me how to do it? can u please give me a sample code.. i want to print a dataset.. is crystal reports a easy way to print? or i have to use print dialogue box?
Printable View
hi,
I have a db and i want to print reports from that.. can u please guide me how to do it? can u please give me a sample code.. i want to print a dataset.. is crystal reports a easy way to print? or i have to use print dialogue box?
What is a db?
Add a PrintDialog and useCode:.ShowPrintDialog
@Eldrup
db = database
@yogesh12
The best way it's like you said using crystal reports, you can do everything with the gui, just drag and drop a crystalreportviewer to a form, then add a new report, and configure everything... datasource, etc...
Oh, then i cant help here, sorry.
can u please give me a piece of code?
its not working please correct my code..PHP Code:Dim da As SqlDataAdapter
Dim constr As SqlConnection
constr = New SqlConnection("xxxx")
Dim cmd As SqlCommand
cmd = New SqlCommand
da = New SqlDataAdapter("Select * from tbl", constr)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
Dim s As New CrystalDecisions.CrystalReports.Engine.ReportDocument
s.SetDataSource(ds)
CrystalReportViewer1.ReportSource = s
CrystalReportViewer1.Refresh()
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
First, the s var need to be the report document that you must have added to you project, something like CrystalReport1... When you add the report a wizard pop's up to configure the report.
Then when declaring the s has to be like this:
VB.NET Code:
Dim s As New CrystalReport1
And everything should work fine...
You've added a new report to your project?
Right click in the solution, add new item, and add new crystal report.
yup added.. condition is same.. :o
Code:Dim constr As SqlConnection
constr = New SqlConnection("xxxx")
Dim cmd As SqlCommand
cmd = New SqlCommand
Dim da As SqlDataAdapter
constr.Open()
da = New SqlDataAdapter("Select name from tbl", constr)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
Dim s As New CrystalReport1
s.SetDataSource(ds.Tables(0))
CrystalReportViewer1.ReportSource = s
CrystalReportViewer1.Show()
constr.Close()
What's the error message?
Are you sure... Maybe you don't have any data in the report...
You must configure the report, to see anything.
To test add a textfield to the report and remove this line:
vb Code:
s.SetDataSource(ds.Tables(0))
When you add a new item, in your case a new report a wizard pop up that let you define the datasource, tables and fields...
If you don't use the wizard, you can configure it, by selecting the report, and access the Field Explorer (normally in the left near the toolbox).
If you can't get it, i can create an example project for you...
Moved To Reporting
Take a look
got error while loading from db :o:o Failed to load from Database, DLL "crdbo_xxx.dll cud not be loaded.. mate i got ur point, but how to set the place where i can insert Datasets? and also is it possible to show each records seperately like
"Emp Name" (in Bold)
Qualification: "Field 1 " (from DB")
Work Exp: "Field 2 " (from DB")
like that?
That must be done at design time, you can't do that at runtime, at least with the version that cames with vs...
1. OPen the report in the main window
2. Open the tab of the field explorer (if you can't see it, just select crystal reports menu and select Field Explorer)
3. In the field explorer, right click in the database fields and then database expert, and configure your connection
4. After this you have a plus sign in the database fields, and you can select fields to insert in the report, drag and drop.
5. To insert other fields, you can use the Toolbox
Yes...
I don't think there's an easy way to do that...
Just think, at runtime, how do you place the items in the report, and format the texts, etc.