Microsoft Access
  Home arrow Microsoft Access arrow Page 3 - 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 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
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: 4 stars4 stars4 stars4 stars4 stars / 50
    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 - Manipulating a Microsoft Access database directly using ASP.NET


    (Page 3 of 6 )

    Once you complete everything as suggested in the previous section, you need to work with one more button, “Add,” within the same application.  Add the following code to the “Add” button available.

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e
    As System.EventArgs) Handles btnAdd.Click
            Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\AccessDB\MyDB.mdb;User Id=admin;Password=;")
            Dim cmd As New OleDbCommand
            With cmd
                .CommandText = "insert into emp (empno,ename,sal,deptno) values (" & Me.txtEmpno.Text & ",'" &
    Me.txtEname.Text & "'," & Me.txtSal.Text & "," &
    Me.txtDeptno.Text & ")"
                .Connection = cn
                .Connection.Open()
                .ExecuteNonQuery()
                .Connection.Close()
                .Dispose()
            End With
            cn.Dispose()
            'refresh the list
            btnList_Click(Nothing, Nothing)
        End Sub

    Once you complete the above, you execute your application (by pressing F5), provide some reasonable values in the textboxes and finally click on the button “Add.”  If you are lucky, you should be able to see the newly added row in the grid. 

    Not everybody will be lucky. Some of you may receive an error, “Operation must use an updateable query.”  That single statement (or error) has several meanings, according to Microsoft.  If you really want to know about the error, you simply copy and paste the error message into the “search” box of the Microsoft website and you will see plenty of explanations focusing on that error. 

    To solve that error in this scenario, you need to change your “web.config” file by providing the necessary “impersonation” configuration.  Open the “web.config” file of your web application and insert the following line just below the  “<system.web>” tag:

    <identity impersonate="true"
     userName="computername\administrator" password="password" />

    Replace the “computername” with your system name and “password” with the password of the “administrator” account.  You can also replace “administrator” with any other customized user account with respective privileges.  I simply demonstrated this using the “administrator” user account.

    Now, you should be able to run without any errors (hopefully).

    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 4 hosted by Hostway