Writing Data into Access Using ADO.Net

Posted on 2007-08-06
Last Modified: 2010-04-23
Hi All,

Im using ADO.Net in my app to read data from an Access database. I'm OK doing this but I'm unsure how to write data back into Access with ADO.Net as I am used to using ADOdb.
Can someone give me a quick example.
Question by:kiranboi
    LVL 18

    Expert Comment

    by:Ajay Sharma
    declare this

    Public myConnection As OleDbConnection

    Public ConnStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & System.Web.HttpContext.Current.Server.MapPath("") & "/db.mdb;"

    then in the webform import this
    Imports System.Data.OleDb

    on the insert button click put this

                        Dim SQL As String
                        Dim comm As OleDbCommand
                        myConnection = New OleDbConnection(ConnStr)

                        SQL = "insert into tblNewsletter (emailid, createdon) values ('" & somveVar  & "','" & Now & "')"

                        comm = New OleDbCommand(SQL, myConnection)
                    Catch ex As Exception
                    End Try

    Author Comment

    just out of interest, is there any way of doing it without using SQL?

    Author Comment

    can you show me an example of updating a record and one of creating a new record and deleteing one
    LVL 18

    Accepted Solution

    Yes, since you say you already know how to fetch data, you just need to add oledbcommandbuilder to generate InsertCommand, UpdateCommand and DeleteCommd for DataAdapter can know how to update data in database. See this link


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now