How to Print Using Crystal Reports

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

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:[email protected]

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...

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 [email protected] 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

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

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: Imports CrystalDecisions.CrystalReports.Engine Imports System.Data.Odbc Imports MySql.Data.MySqlClient Public Class reporter 'Dim custReport As CrystalReport1 Dim myReport As New ReportDocument Dim myData As New DataSet1 Dim conn As New MySqlConnection Dim cmd As New MySqlCommand Dim myAdapter As New MySqlDataAdapter Private Sub reporter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load conn.ConnectionString = "server=localhost;uid=root; pwd=; database=boutique" Try conn.Open() cmd.CommandText = "Select CatName As Category, Quantity from ttbcategory" cmd.Connection = conn myAdapter.SelectCommand = cmd myAdapter.Fill(myData) myReport.Load("C:\Users\Shengbelen\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\CrystalReport2.rpt") myReport.SetDataSource(myData) CReportViewer.ReportSource = myReport Catch ex As Exception MessageBox.Show(ex.Message, "Report could not be created", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class The above code is for my form with the crystalReportViewer The following code is for my print command. Private Sub PrintCtrlPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintCtrlPToolStripMenuItem.Click reporter.ShowDialog() End Sub Please help Eric

In reply to by Anonymous (not verified)

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?

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

In reply to by Anonymous (not verified)

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

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. [email protected]

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 [email protected]

In reply to by Anonymous (not verified)

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.

In reply to by Anonymous (not verified)

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

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 [email protected]

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??

In reply to by Anonymous (not verified)

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!!!

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 [email protected]

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. [email protected]

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 [email protected]

Add new comment