how to print dbgrid data ?

like this,

the question is , how do we print the data that we has retrieave in  dbgrid control  by using sql in data control to be printed to the printer. lets say i succesfull retriave data  by using sql statement.

                      select xxxx from xxxx where xxxx = " xxx " and this showing some found data in the dbgrid which has been connected to data control.

                      so i want to print that data to printer .

                      how ?
JOHNHOAsked:
Who is Participating?
 
aleshConnect With a Mentor Commented:
You could write your own control to print this data to the printer, but I belive that will be too much time consuming and also hard to do.
You need to use either a 3rd party control (like Crystal Reports, Videosofts VsView, etc...) or if you have VB 6.0 (pro and ent) you can you it's report engine.
How to send the data to the printer is then handled by the control you only have to worry how and in which form the data will come to the control and design the output of the paper.

Best wishes,
Alesh
0
 
JOHNHOAuthor Commented:
ok if it like that.

so lets say im using crystal report, then how do i print the thing that i want to print.(not saying that i choose on the design
report ).

then what i mean that after i reatrive the data by using sql then that found data will go directly to crystal report. so how do i do it ?


 
0
 
aleshCommented:
Ok, if you would be using crystal report (CR) it's like this:
instead of retriving the data using sql in your application, you pass the sql string to the CR via the formula property.
For example:
cr.formula = "SELECT * FROM AUTHORS WHERE FirstName Like %John%"
cr.action 1 'tho i'm not sure about this line

And that's it, you design the report in CR almost the same way as you would design it in Access or a document in Word. By drawing it and putting fields on it.

CR will take care of everything else (considering the SQL string).

I hope this answered your question. If not please provide me back which part wasn't clear to you.

Best wishes,
Alesh
0
 
JOHNHOAuthor Commented:
it is cannot work.

it show me argument not optional.


0
 
aleshCommented:
I cannot give you step by step instructions how to make this. I answered your question how to do it and with what. I belive that should be enough to accept my answer!

Alesh
0
All Courses

From novice to tech pro — start learning today.