Hi. I'm trying to print from datagridview but I don't understand how to do it. I've found some coding and this is the best for me.


But the tutorial is using server and I'm using this to call my table from Acces to datagridview. I don't know where to replace the tutorial with my coding.

Imports System.Data.OleDb

    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String
    Dim dv As DataView

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As DataSet
        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\~LaiLi~\My Documents\Visual Studio 2005\Projects\MoreWever\MoreWever\bin\Debug\Inventory.mdb"
        Dim cn As OleDbConnection

        cn = New OleDbConnection(ConStr)
        ds = New DataSet
        dv = New DataView
        Dim ad As New OleDbDataAdapter("SELECT * FROM Sales", cn)
        ad.Fill(ds, "Sales")
        dv.Table = ds.Tables("Sales")
        Me.DataGridView1.DataSource = dv

    End Sub

I don't understand [Public Function GetData() As DataView] part. And when I try the coding, though the PrintPreviewDialog shown nothing, it open a window that I have to choose something from it. That part I don't understand too. Or maybe you guys have other codings, I really appreciate it. Please check it for me. Thank you.

7 Years
Discussion Span
Last Post by msrd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.