|
-
Aug 6th, 2003, 03:11 PM
#1
Thread Starter
Member
Here are 3 working for Add/Delete/Update Records in a Access File
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()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|