Here are 3 working for Add/Delete/Update Records in a Access File

mrdutchie

Well-known member
Joined
Jul 7, 2003
Messages
78
Location
WI, USA
Thought I would share this with you, since you all helped me out.


*** ADD RECORDS ***
value1 = "hello"
value2 = "there"
Dim mycon As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/database.mdb")
Dim mycmd As OleDbCommand = New OleDbCommand
mycmd.Connection = mycon
mycmd.CommandText = "INSERT Into email (name,email) Values (" & Value1 & "," & Value2 & ")"
mycon.Open()
mycmd.ExecuteNonQuery()
mycon.Close()


*** DELETE RECORDS ***
Dim mycon As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/database.mdb")
Dim mycmd As OleDbCommand = New OleDbCommand
mycmd.Connection = mycon
mycmd.CommandText = "DELETE FROM email WHERE name=hello"
mycon.Open()
mycmd.ExecuteNonQuery()
mycon.Close()


*** UPDATE/EDIT RECORDS ***
Dim mycon As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/database.mdb")
Dim mycmd As OleDbCommand = New OleDbCommand
mycmd.Connection = mycon
mycmd.CommandText = "UPDATE email SET email=no e-mail WHERE name=hello"
mycon.Open()
mycmd.ExecuteNonQuery()
mycon.Close()
 
Back
Top