Login   /   Register

Add a New Record to a Table

Rate this article
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...
April 1st, 2008 by daniva

The following code demonstrates how to add a new record to a table. The example uses the Flight Reservation Database.

Const adOpenStatic = 3
Const adLockOptimistic = 3
 
Set oConn = CreateObject( "ADODB.Connection" )
Set oRst = CreateObject( "ADODB.Recordset" )
 
oConn.Open "QT_Flight32"
 
oRst.Open "SELECT * FROM Flights" , oConn, adOpenStatic, adLockOptimistic
 
oRst.AddNew
oRst( "Flight_Number" ).Value = 21000
oRst( "Departure_Initials" ).Value = "TLV"
oRst( "Departure" ).Value = "Tel Aviv"
oRst( "Day_Of_Week" ).Value = "Sunday"
oRst( "Arrival_Initials" ).Value = "BSA"
oRst( "Arrival" ).Value = "Buenos Aires"
oRst( "Departure_Time" ).Value  = "11:00 PM"
oRst( "Arrival_Time" ).Value = "11:00 AM"
oRst( "Airlines" ).Value = "EL-AL"
oRst( "Seats_Available" ).Value = 220
oRst( "Ticket_Price" ).Value = 1400
oRst.Update
oRst.Close : oConn.Close
Set oRst = Nothing : Set oConn = Nothing

Posted in ADODB

Leave a Reply

You must be logged in to post a comment.

This article was viewed 656 times