Click here to Skip to main content
15,845,681 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am learning to connect access2007 and how to use grid view in
Please send the one example for grid View & access 2007?

Dear Vijaya,

This link may help you out for GridView:-[^]

link for access connection:-[^]
Share this answer
Try this code......

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MSACCESSGV.aspx.cs" Inherits="MSACCESSGV" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">

<form id="form1" runat="server">

<asp:GridView ID="gvArticle" runat="server" AutoGenerateColumns="False">
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Id" />
<asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Title" />
<asp:BoundField DataField="Published" HeaderText="Published" SortExpression="Visit" />
<asp:BoundField DataField="Modified" HeaderText="Modified" SortExpression="Modified" />



Now you need to write code in server side to bind GridView gvArticle. First make connection string for your MS Access Database. And then read data from MS Access database. Complete server side code is given below:
using System;
using System.Data;
using System.Web.UI;
using System.Data.OleDb;

public partial class MSACCESSGV : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)
string sFilePath = Server.MapPath("MSACCESS.mdb");
DataTable dt;
OleDbConnection Conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sFilePath + ";");

using (Conn)
OleDbCommand cmd = new OleDbCommand("SELECT * FROM ARTICLE", Conn);
OleDbDataAdapter oDA = new OleDbDataAdapter(cmd);
dt = new DataTable();

gvArticle.DataSource = dt;

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900