Link to home
Start Free TrialLog in
Avatar of kiranboi
kiranboi

asked on

Writing Data into Access Using ADO.Net

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.
Thanks
Avatar of Ajay Sharma
Ajay Sharma
Flag of India image

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

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

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

                    comm = New OleDbCommand(SQL, myConnection)
                    comm.ExecuteNonQuery()
                    myConnection.Close()
                Catch ex As Exception
                   'Response.Write(ex.Message)
                End Try
Avatar of kiranboi
kiranboi

ASKER

just out of interest, is there any way of doing it without using SQL?
can you show me an example of updating a record and one of creating a new record and deleteing one
thanks
ASKER CERTIFIED SOLUTION
Avatar of Priest04
Priest04
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial