VisualBuilder
  Home > Aspnet > Tutorials > Connecting Access Database with AccessDataSource and GridView Control - ASP.NET Database Tutorial
Tell a friend
Link to us
Total Members
      Members: 84657
     
Sitemap Forum Chat
Home
ASP.NET Database Tutorial Home
1 . Introduction to Asp.Net 2.0
2 . Introduction to ADO.Net
3 . Connecting Access Database with AccessDataSource and GridView Control
4 . Accessing SQL SERVER Database [Using SqlDataSource]
5 . Storing Connection String in Web.Config File
6 . Inserting Records in Database
7 . Updating Records in Database
8 . Updating Records in Database
9 . Deleting Records from Database
10 . Execute Scalar: Getting Single Value from the Database
11 . Execute Reader: Fetching Records from Database
12 . Data Adapter
13 . Data Adapter and Database Connection
14 . Performing Batch Updates: Using SqlCommandBuilder
15 . Improving Performance using Stored Procedure
16 . Filtering and Sorting Data Using DataView/DataTable
17 . Data Binding and Data Synchronization
18 . SQL Transaction and Locking
19 . SQL Joins and .Net
20 . Automatically Generation of SQL Statement
 
Aspnet Group Home
Aspnet Discussion (10)
Aspnet Members (2382)
Aspnet Resources
Aspnet Source Code (388)
Aspnet Articles (1)
Aspnet Blogs
Aspnet Jobs
Aspnet Components (201)
Aspnet Books
Aspnet Websites (21)
Aspnet News (105)
Aspnet Q & A (114)
- Aspnet Ask Question
- Aspnet Questions
- Aspnet Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (434 )
Source Code (3275 )
Articles (11 )
Components (1595 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise

Aspnet database Tutorial
 Connecting Access Database with AccessDataSource and GridView Control
  << Prev: Introduction to ADO.Net Next: Accessing SQL SERVER Database [Using SqlDataSource] >>

ASP.NET 2.0 includes an AccessDataSource control for exposing data from an Access database to an ASP.NET 2.0 (.aspx) page. The control has a simple set of properties. The most important property of AccessDataSource is the DataFile property, which points to the path of the MDB file on disk. The following are the steps to include the control on the page:-


 



  1. Open the Toolbox > Go to Data tab > Drag and Drop “AccessDataSource” control on the webform.

  2. A popup windows appear, which will ask to “Choose a Database” by using the browser window or enter the name of the Mdb format file.

  3. Now the wizard will ask for “would you like to retrieve data from the database?” . Here you can have the option either you can specify a custom SQL statement or stored procedure or Specify columns from a table or view.

  4. Once you move further, the wizard will ask you to view the data that is returned by the SQL query that you mentioned earlier. Here you have to click on the “Test Query” button to view the query result.

  5. Click on the “Finish” button to end.


GridView Control :


Use GridView Control to view all the data that is there in the “tblUser”. Here by clicking on the arrow, you can assign the data source property of the grid view to the accessdatasource id, then all the columns that is there will be displayed with the help of GridView Control.


 


 


Pros and Cons of Access Database


 


The following are the pros and cons associated with the Access database.



  1. Access works very well as a desktop database, and the interface is familiar to many readers. Many small offices have resources already stored in Access MDB files.

  2. Access does not scale to support more than a few users simultaneously.

  3. The problem with Access is that it was never designed to handle execution in a fast-paced, multi-threaded environment such as a Web server. Access was designed and intended as a single- or few-user desktop database.

  4. Access simply does not provide enough performance to run a public Web site effectively and may actually produce unpredictable results under these conditions.

  5. Access also creates development challenges when using parameterized SQL statements, particularly when values must be provided in order to be written to the database. When using parameters, Access correlates the values to fields based on the order in which the values are presented. This is sometimes difficult to manage if the order of fields in your form does not match the order of fields in your SQL.


Example: Demonstrate Accessing MS Access through VS.Net and displaying results.


 


<%@ Page Language ="C#" AutoEventWireup ="true" CodeFile ="Access1.aspx.cs" Inherits ="Access1" %>


 


<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


 


<html xmlns ="http://www.w3.org/1999/xhtml">


<head runat ="server">


</head>


<body>


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


<div>


 


<asp:Label ID ="Label1" runat ="server" Text ="Accessing Access Database">


</asp:Label>


 


<asp:AccessDataSource ID ="AccessDataSource1" runat ="server" DataFile ="~/App_Data/Accessdb1.mdb" SelectCommand ="SELECT [userId], [userName], [password], [designation], [address] FROM [tblUser]"> 


</asp:AccessDataSource>


<asp:GridView ID ="grdvUser" runat ="server" AutoGenerateColumns ="False" DataKeyNames ="userId" DataSourceID ="AccessDataSource1">


<Columns>


<asp:BoundField DataField ="userId" HeaderText ="userId" ReadOnly ="True" SortExpression ="userId" />


<asp:BoundField DataField ="userName" HeaderText ="userName" SortExpression ="userName" />


<asp:BoundField DataField ="password" HeaderText ="password" SortExpression ="password" /> 


<asp:BoundField DataField ="designation" HeaderText ="designation" SortExpression ="designation" />


<asp:BoundField DataField ="address" HeaderText ="address" SortExpression ="address" />


</Columns>


</asp:GridView >


</div>


</form>


</body>


</html>


 


 


Note:- User can also add the SQL query for selecting some specific data into the Grid by adding the SQL directly into the grid property.


  << Prev: Introduction to ADO.Net Next: Accessing SQL SERVER Database [Using SqlDataSource] >>
Aspnet Database Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
conference call
MSN
Video Surveillance
VoIP Internettelefonie DE
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising