|
|
|
|
|
| | |
Using ADO to add a new record.
In this example we are using ADO to add a new record.
We are also populating a couple fields at the same time but that part is not mandatory
though usually makes sense to do that.
This is just an example to get you started.
<%
NAME = "Teddy Gordon" %>
<% MESSAGE = "This is a test" %>
<%
' declaring variables
' not neccesary but a good habit
Dim DataConn
Dim CmdAddRecord
Dim MYSQL
Set DataConn = Server.CreateObject("ADODB.Connection")
Set CmdAddRecord = Server.CreateObject("ADODB.Recordset")
' The line below shows how to use a system DSN instead of a DNS-LESS connection
' DataConn.Open "DSN=System_DSN_Name"
DataConn.Open "DBQ=" & Server.Mappath("../_database/database.mdb")
& ";Driver={Microsoft Access Driver (*.mdb)};"
MYSQL = "SELECT some_table.* FROM some_table"
CmdAddRecord.Open MYSQL, DataConn, 1, 3
CmdAddRecord.AddNew
CmdAddRecord.Fields("NAME") = NAME
CmdAddRecord.Fields("MESSAGE") = MESSAGE
CmdAddRecord.Update
' closing objects and setting them to nothing
' not neccesary but a good habit
CmdAddRecord.Close
Set CmdAddRecord = Nothing
DataConn.Close
Set DataConn = Nothing
%>
|
|
|
|
|
|
|
|
|
|