Print Access database records on Button click in ASP.Net

on Aug 19, 2018 02:04 AM

Can anybody please help in coding to print Microsoft Access Database along with some additional information in in vb on the click of a button, Please???

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Aug 20, 2018 12:22 AM

Hi ShihabKhan,

Please follow the below steps.

1. Read the data from access database and bind in GridView inside a ASP.Net Panel.

For reading data from access database refer below links.

How to connect MS Access DataBase in ASP.Net using VB.Net

jQuery AutoComplete TextBox using Microsoft Access Database in ASP.Net

2. Print ASP.Net Panel contents using JavaScript.

Print ASP.Net Panel contents with Print Preview using JavaScript

on Aug 20, 2018 09:54 AM

Thanks dharmendr for helping me, you have found out the exact solution which I required, but a small problem , Although it prints the required data along with some contents like " DIV Contents      Page 1 of 1    http://localhost:1804/===.aspx                8/20/2018"  which is not at all required by me, So could you please help me in removig those unneccessary contents in the print Please.

on Aug 21, 2018 01:01 AM

Hi ShihabKhan,

There are handled by user itself.

To remove from chrome add the below line style.

<style type="text/css">
        margin: 0;

To remove from mozilla add tmoznomarginboxes mozdisallowselectionprint in the head tag.

<script type="text/javascript">
    function PrintPanel() {
        var panel = document.getElementById("<%=pnlContents.ClientID %>");
        var printWindow ='', '', 'height=400,width=800');
        printWindow.document.write('<html moznomarginboxes mozdisallowselectionprint><head><title>DIV Contents</title>');
        printWindow.document.write('</head><body >');
        // remove title from IE.
        printWindow.document.title = '';
        setTimeout(function () {
        }, 500);
        return false;

For IE you can not control it with javascript. You can remove only the title.