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 ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 ?

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,
JOHNHOAuthor Commented:
it is cannot work.

it show me argument not optional.

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!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.