Loading

How to Print Using Crystal Reports

Submitted by: 
Language: 
Visitors have accessed this post 105287 times.


This tutorial is part of Database Programming Made Easy Series.

How to Print Using Crystal Reports

Somebody is asking if I can add sample on how to print a report. So here it is. I just tweak some little changes from our previous tutorial on Windows Forms – CheckBox Control.

I did not test this from other computer so if you encounter problem on the database location just change the report data source to the directory where you save this files.

Previous: Windows Forms - TreeView Control



Download Code: 

Comments

Hi, i'm eva, from Bicol..I have a senior project "enrollment system". Is there a code needed for me to connect Oracle to VB.net?i just found a code for the connection of MySql and Vb.net. Can you help me create an admin module?...please???tnx in advance.
this is my email add:esketcher07@yahoo.com

use con1 as new OracleClient.OracleConnection

admin's picture

I don't use oracle but all you need is to define that connection string for oracle and you're done.

What kind of admin module?

but are you using vb.net?i don't know how make an admin..if not,can you help me in the print module?Like for the enrollment, my project should generate an assessment that contains the subjects and payment info.....

Hi sir, just wnt to ask f you know how to retrieve data from sql using label in vb.net. tnx in advance...

admin's picture

A textbox and a label control works the same.

I am using c# vs 2008 and Crystal Reports.
In the preview there is no problem, but then when I run the program, I can't see the report because it ask for login.
I don't have user and password.
I have been searching for a long, but I coudn't find anything.
my mail is florencia.sarasua@gmail.com

Thanks for any help
Florencia

Hi, It is likely the username and pwd of your sql server needs to be provied to view your report. In the codeview you can set the databaselogon details which will bypass the logon page and displays the report directly.

exg:

MyCrReport crReportObj = new MyCrReport();
crReportObj.SetDatabaseLogon("sa", "sa", "ADPL-BLR119", "northwind");

CrystalReportViewer1.ReportSource = crReportObj;

Hope this may fix your problem.

Thanks,
Bala.

hi, just want to ask sir if you know how to convert the string to a date.i have 3 comboBox for Day,Month, and Year.It is for birthdate and the data type is date..but i'm having hard time in vb..please help me..tnx po

admin's picture

  1. dtpBirthDate.value = Format(cboDay.Text & "/" & cboMonth.Text & "/" & cboYear.Text, "Short Date")

Hi Good morning Sir! Uhmm. just wanna ask if you can create a simple date range say for example 2 textboxes start date and end date or even datepicker will do. Only the results will be print not all the data in the database. Thank you Sir

admin's picture

Kindly download the hotel reservation system and look at the code on how to print report with date range.

I have been try for days to load mysql field data onto a crystal report using vb.net on vs 2008 but to no avail. I keep getting the report with just the field headings but no field data at runtime. Upon previewing (not at runtime) I get some unknown data showing under my field headings. I have tried almost all the posts on the internet. What do I do now?
This is my code:

  1. Imports CrystalDecisions.CrystalReports.Engine
  2. Imports System.Data.Odbc
  3. Imports MySql.Data.MySqlClient
  4.  
  5. Public Class reporter
  6. 'Dim custReport As CrystalReport1
  7. Dim myReport As New ReportDocument
  8. Dim myData As New DataSet1
  9. Dim conn As New MySqlConnection
  10. Dim cmd As New MySqlCommand
  11. Dim myAdapter As New MySqlDataAdapter
  12.  
  13.  
  14. Private Sub reporter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  15. conn.ConnectionString = "server=localhost;uid=root; pwd=; database=boutique"
  16.  
  17. Try
  18. conn.Open()
  19.  
  20. cmd.CommandText = "Select CatName As Category, Quantity from ttbcategory"
  21. cmd.Connection = conn
  22. myAdapter.SelectCommand = cmd
  23. myAdapter.Fill(myData)
  24.  
  25. myReport.Load("C:\Users\Shengbelen\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\CrystalReport2.rpt")
  26. myReport.SetDataSource(myData)
  27. CReportViewer.ReportSource = myReport
  28.  
  29. Catch ex As Exception
  30. MessageBox.Show(ex.Message, "Report could not be created", MessageBoxButtons.OK, MessageBoxIcon.Error)
  31.  
  32. End Try
  33. End Sub
  34.  
  35.  
  36. End Class

The above code is for my form with the crystalReportViewer

The following code is for my print command.

  1.  
  2. Private Sub PrintCtrlPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintCtrlPToolStripMenuItem.Click
  3.  
  4.  
  5. reporter.ShowDialog()
  6.  
  7.  
  8. End Sub

Please help
Eric

admin's picture

Did you get any data when you preview your report using VB Editor at design time?

Hello,

Can the solution be implemented to print from a form or menu in VB6 with CR9?

help me

hi,
just want to ask if you know how to get other data from a table.Example, when i click a value from a combo box it should automatically output the other data like the values in the combo box are subject codes,if i choose 1 subject it should output the subject title,units,..etc..
tnx

admin's picture

Your question seems not clear. Do you mean a one-to-many relationship?

Like after selecting a value from a combobox another data will appear in the datagrid?

i have crystal report and DataSet1.xsd doc i want to acces data in crystal report regard who user login but and also i take three diff adapter in xsd file with scaler vaiable of userID but it not function please help me.

How to use the crystal report in C# Visual studio 2008 express edition,express edition does not support crystal report,is there any way to generate the report in express edition

admin's picture

I think no. You can download the trial version of Visual Studio for free for 90 days at http://www.microsoft.com/visualstudio/en-us/try/default.mspx.

i downloaded your code but when i try to run your program it runs but when i tried to do print it ask me about the password you enter in your sql connection. can you please send me your password, for me to be able to view your sample crystal report.

thanks in advance.

wellcom34@yahoo.com

admin's picture

Thank you for reporting this bug. I have already uploaded the fix for this. Please download the code again.

I write a note on this also on Crystal Reports Tutorial Update.

hello sir i want the database password from hotal reservation using crystal report

Qry = "SELECT code,name,amount FROM balance3"
Set Rs2 = New ADODB.Recordset
Rs2.CursorLocation = adUseClient
Rs2.Open Qry, db, adOpenDynamic, adLockOptimistic
If Rs2.RecordCount > 0 Then
Set DataGrid3.DataSource = Rs2

---------
how to get sum of datagrid
pls send me code

malabar2009@yahoo.com

thanx

i want to print bill for a specific record using crystal reports. i'm using vb.net. i'm beginner n dont know how to do it . plz help me to solve this problem.

admin's picture

Please read and download the source code above.

hi admin. i'm so impressed of your skills..

you made me realize that programming field is easy..:)

im still a novice using VB and im starting to read about PHP and MySQl..

hope you can be my 'teacher' on this field.. thanks.

more power.:D

admin's picture

Thank you

what is the code of crystal report without need a password in vb net 2008
this is my email add:
rabih_fl@hotmail.com

admin's picture

Please download again the code above. I have already fixed it.

How do you make report to print only a row of data? And not the entire data on the database

if you can please put c# code
i don't realize vb
my mail mohamad.moein@gmail.com

sir i need crystal report with vb.net (useing 2 table one master having address of party and 2 is transtaion table i want to gv billno from trasation table i need its print but address of party is with first table(master) will u help me both table shoud be in sql server

can i use crystal report in PHP system??i'm now doing
e-timesheet system using PHP..so,now,i need to do a report from that timesheet..so,can crystal report solve it??or i need another method??

admin's picture

Yes you can as long as you know the method. For your reference please read this: http://us2.php.net/manual/en/ref.com.php#72955.

I always use pdf as a reporting tool for my PHP script so I cannot really give you an idea on how to do this.

is it possible to print unlimited data using crystal report?
kasi ang pwede lng iprint during run time is < 20 copies lng and pag sumobra nagkakaroon ng runtime error '20544'.. panu po ba ito madebug?

sir i have to show listbox items in crystal reports with their respective data stored in their database?

ex: listbox items contain only name of the student while printing i have to show their stream class & rollno in the crystal reports...

please help me sir!!!

Plz send vb code for take input from weight machine

Plz

My email is Kanji_patel10@yahoo.com
kanji.keraliya@gmail.com

Plz

IS IT POSSIBLE TO PRINT LIKE THIS IN VB6

what if I am using sql database not access or any dataset
how do I print crystal report? pls give me the codes...

how to connect several mdb databases for one crystal report at runtime in C# coding give some sample code

admin. i tried ur code but when i change the path of the datbase(i transfered to drive C) i got an error stating that it was an invalid path. how was that?

i want a report using programatically(using sql,select statement just like in vb 6.0)
w/o using any dataset. Help Please. Crystal report or RDLC

for instance:
I design the report (2 txtboxes/field) then i will select a data(Select * from table where ID = 'values')

then what i want is that fill the two txboxes/field in the crystal report with the requested data(base on the request(select statement))

NEED IT! Tnx sir!

I want to print Barcode report accocrding to quantity which is sale to a customer.
the barcode print in many times ,as the quantity of product, how to do it by coding
send me on shama439@gmail.com

i have five tab page and inside of it there are many textbox that is linked into a database using access.....plz help

sorry for the english

Hi Jaypabs. I was checking your code. I really need you help me with a sample. If I have not included my *.mdb file in my project ¿how can I change the pathfile where the program is deployed? ¿Could you add this code in your example ? I'm using vb.net 2008 and access 2007.
I will apreciate your help.

hruixs@yahoo.com

Hello hw can I get this application in C-sharp or how do I lay hands on C-Sharp reporting

sir,
i need the code to transfre textbox data to crystal report so sir if you have a code than sir please send it in my email id chavdakankasinh@gmail.com

Pages

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.