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
kiranboiAsked:
Who is Participating?
 
Priest04Commented:
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

http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbcommandbuilder.aspx

Goran
0
 
Ajay SharmaCommented:
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
0
 
kiranboiAuthor Commented:
just out of interest, is there any way of doing it without using SQL?
0
 
kiranboiAuthor Commented:
can you show me an example of updating a record and one of creating a new record and deleteing one
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.