Microsoft Access
  Home arrow Microsoft Access arrow Page 4 - Connecting to a Microsoft Access database ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MICROSOFT ACCESS

Connecting to a Microsoft Access database with ASP.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 55
    2006-04-04

    Table of Contents:
  • Connecting to a Microsoft Access database with ASP.NET
  • Connecting to a Microsoft Access database directly using ASP.NET
  • Manipulating a Microsoft Access database directly using ASP.NET
  • Connecting to a Microsoft Access database through ODBC using ASP.NET
  • Manipulating a Microsoft Access database through ODBC using ASP.NET
  • Connecting to a password protected Microsoft Access database directly using ASP.NET

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Connecting to a Microsoft Access database with ASP.NET - Connecting to a Microsoft Access database through ODBC using ASP.NET


    (Page 4 of 6 )

    I need to warn you before you use this method.  Working with ODBC really slows down the performance of your application.  In general, ODBC is used to connect to non-Microsoft data sources.  In this scenario, I just wanted to show you how to connect through ODBC.  For the sake of simplicity, I'm using Microsoft Access 2003 as an example.

    Try to create a new web application using Visual Studio.NET (I named mine “ConnectAccessODBC” for this demonstration).  Design your web form with the same layout as shown in the first section of this article.

    After designing the form, switch to the code and add the following line at the top.

    Imports System.Data.Odbc

    I am importing the namespace “System.Data.Odbc” because I would like to connect to the Access database using the ODBC provider for .NET.  You can connect to any data source supported by ODBC.  Add the following code to your “show/refresh” button:

     Private Sub btnList_Click(ByVal sender As System.Object, ByVal e
    As System.EventArgs) Handles btnList.Click

            Dim cn As New OdbcConnection("Driver={Microsoft Access
    Driver (*.mdb)};DBQ=c:\AccessDB\MyDB.mdb")
            Dim da As New OdbcDataAdapter("select * from emp", cn)
            Dim dt As New DataTable
            da.Fill(dt)
            da.Dispose()
            cn.Dispose()
            Me.DataGrid1.DataSource = dt
            Me.DataGrid1.DataBind()
        End Sub

    You need to modify the connection string with the proper “database driver” registered in ODBC, according to your data source.  Once you complete the above, you execute your application (by pressing F5) and click on the button “Show/Refresh.”  You should be able to see all the rows on the screen.  Now, let us proceed to the next section.

    More Microsoft Access Articles
    More By Jagadish Chaterjee


       · Hello guys, now you can feel free in connecting to MS Access from within ASP.NET. ...
       · i am working on asp.net applications when i am trying to access MSACCESS database it...
       · hello sir,i am working on asp.net , i tried to implement this posting for...
       · It's Very Nice Article to work with MSAccess DataBase, When database was in the...
       · hello sir how to connect the asp.net with ms access database conntivity with steps...
     

    MICROSOFT ACCESS ARTICLES

    - Linking SQL Express 2005 Tables to MS Access...
    - Working with Access Projects in Access 2007
    - Exploring Access 2007
    - Working with Stored Procedures in an MS Acce...
    - Creating and Using Action Queries
    - Creating Data Access Pages with Charts using...
    - Advanced Ideas using VBA
    - VBA Details
    - Updating Records in MS Access
    - Using ADO`s Record Object with URLs
    - Exporting XML from MS Access 2003
    - Importing XML into MS Access 2003
    - On Using Pass-through Queries in MS Access
    - Distributed Queries in MS Access
    - Configuring a Linked Microsoft Access Server...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT