Sullivan Market

a web based full-circle development system



My ASP Tutorials - Inserting Data into a Database:

Working With Databases -- The Insert Statement:
     The next task you want to become familiar with after mastering the select statement, is the insert statement. What this statement does is allow the user to add, or insert, a record into one or multiple tables within a given database. In this example we are adding several pieces of information into a single table. In order to complete this task you have to connect to the database, retrieve the information you want to insert, know the table name(s) and column name(s) that correspond to the data you wish to insert, and make sure that the variable types you have for each value match their partner within the table. In other words, you don't want to insert an integer into a column that requires a string of text. Refer to the example below for a visual explanation of the insert statement.

<%
Dim strSQL

strSQL="INSERT INTO TableName (variable1,variable2, variable3, variable4, variable5,
variable6, variable7) Values (" &_
"'" & variable1 & "', " &_
"'" & request.form("variable2") & "', " &_
"'" & request.form("variable3") & "', " &_
"'" & request.form("variable4") & "', " &_
"'" & request.form("variable5") & "', " &_
"'" & request.form("variable6") & "', " &_
"'" & request.form("variable7") & "')"
rsCat = dcnDB.execute(strSQL) %>

Back To ASP Tutorials

©2012 SullivanMarket.com