views:

96

answers:

2

I want to convert the ms access data into a document so that the print function in vb.net will read it. Where do I start from here? Here is my form: http://screencast.com/t/MGU4N2UyNmY And here is the code for print preview.

     Try
            PrintPreviewDialog1.ShowDialog()
        Catch es As Exception
            MessageBox.Show(es.Message)
        End Try

How do I incorporate the above code, to the code below so that there is something that can be seen when I hit the print button?

 Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\search.mdb")
        Dim cmd As OleDbCommand = New OleDbCommand("Select * from GH where NAME= '" & TextBox6.Text & "' ", cn)

        cn.Open()

        Dim rdr As OleDbDataReader
        rdr = cmd.ExecuteReader




        If rdr.HasRows Then
            rdr.Read()
            NoAcc = rdr("NAME")
            If (TextBox6.Text = NoAcc) Then TextBox1.Text = rdr("IDNUMBER")
            If (TextBox6.Text = NoAcc) Then TextBox7.Text = rdr("DEPARTMENT")
            If (TextBox6.Text = NoAcc) Then TextBox8.Text = rdr("COURSE")

        End If

Please help,thanks

+2  A: 

There's lots of XML/HTML to PDF writers out there. My suggestion is that you build up a HTML page and use a conersion library that will give you a pdf file, then just use normal print functions on it.

But you still need to 'render' the data somehow. IN a graph? In a table? That's up to you of course. Raw data is just memory pointers and isn't printable until you format it somehow.

You could also check out reporting technologies like Crystal Reports. They let you design a report, bind to data, and to print to PDF as well.

DarkwingDuck
but could I atleast print the data that is viewed through the textbox or datagridview
A: 

You need a printdocument object/control to use the printing methods in vb. This object controls what is sent to the printer and can be used for the dialogs eg print preview.

The user simply needs to select a pdf printer for it to be converted to PDF then.

Also why are you using VB.net? There are features in ms-access that allow you to print a query? eg Forms, Querys, Reports.

mikek3332002
The MS-ACCESS tag is often used misleadingly, by people who don't understand the distinction between Access the development environment and the Jet/ACE database engine. It's likely Access is not in use here, only and MDB/ACCDB file for data storage. At least, that would be my guess.
David-W-Fenton
I'm aware of the difference he could even do the query from excel. My point was to try out the purpose of the VB/jet application to work out whether there are better solutions available.
mikek3332002