ASP ADO Insert
Insert one row with explicit parameter types.
How it works
An INSERT creates a row, so decide its identifier and constraints before writing it. Parameters keep text such as apostrophes as data. ADO command options can suppress an unused rowset. The complete example writes only to a freshly generated teaching database.
Use the separate Windows lab
This is a legacy-maintenance course. Classic ASP uses IIS and VBScript; ASP.NET Web Pages uses .NET Framework and Razor. Neither runs in PHP, Apache or Bhylu’s browser playground. The reviewed baseline is 32-bit IIS Express 10.0.2001, .NET Framework 4.8, Web Pages / Razor 3.2.9 and the Windows VBScript engine. ADO database examples use the actual 32-bit Jet OLE DB 4.0 provider, not SQL Server or XAMPP MySQL.
Download download-lab.mjs into a separate empty learning folder. Run node download-lab.mjs to fetch hash-checked source files into a new bhylu-asp-lab folder, then cd bhylu-asp-lab and node run-lab.mjs --start. Before deployment, local preview uses node download-lab.mjs http://127.0.0.1:8000/examples/asp/. The source downloader refuses an existing destination. Review its source before running it.
The foreground launcher needs your own 32-bit IIS Express installation with Classic ASP, .NET Framework 4.8 and the VBScript engine available. It downloads the three pinned Web Pages packages from NuGet into its private cache, binds only localhost on port 8142 and stops when you press Ctrl+C. Keep its console open. Visit http://localhost:8142/ado-insert.asp. It does not install IIS, enable Windows features, change Apache/PHP/MySQL, or publish any files. See the bundled README.txt for manual setup and test boundaries.
Each complete Classic ASP source requires the supplied Global.asa acknowledgement; Web Pages uses _PageStart.cshtml. Database and file examples create owned temporary files only under this private lab’s blocked App_Data folder. Sources are public text downloads; do not upload them as executable teaching endpoints on Bhylu.
Example
<%@ Language="VBScript" CodePage="65001" %>
<% Option Explicit
Response.Buffer = True
Response.ContentType = "text/plain"
Response.Charset = "utf-8"
If Application("BhyluLab") <> "YES" Then
Response.Status = "403 Forbidden"
Response.Write "Use the separate Bhylu learning lab."
Response.End
End If
Dim fso, dbFile, catalog, cn
Set fso = Server.CreateObject("Scripting.FileSystemObject")
dbFile = fso.BuildPath(Application("BhyluData"), fso.GetTempName & ".mdb")
If fso.FileExists(dbFile) Then Err.Raise 5, , "Refuse an existing database"
Set catalog = Server.CreateObject("ADOX.Catalog")
catalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbFile
Set cn = catalog.ActiveConnection
cn.Execute "CREATE TABLE Workshops (Id INTEGER PRIMARY KEY, Label TEXT(60), Seats INTEGER)"
cn.Execute "INSERT INTO Workshops VALUES (1,'Mending basics',3)"
cn.Execute "INSERT INTO Workshops VALUES (2,'Patchwork circle',0)"
cn.Execute "INSERT INTO Workshops VALUES (3,'Button repairs',2)"
Dim cmd, changed
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
cmd.CommandText = "INSERT INTO Workshops (Id, Label, Seats) VALUES (?, ?, ?)"
cmd.Parameters.Append cmd.CreateParameter("id", 3, 1, , 4)
cmd.Parameters.Append cmd.CreateParameter("label", 202, 1, 60, "Darners' circle")
cmd.Parameters.Append cmd.CreateParameter("seats", 3, 1, , 2)
cmd.Execute changed, , 128
Response.Write "Inserted: " & changed & vbLf
Response.Write cn.Execute("SELECT Label FROM Workshops WHERE Id=4")(0)
Set cmd = Nothing
cn.Close
Set cn = Nothing
Set catalog = Nothing
fso.DeleteFile dbFile
Set fso = Nothing
%>
Focus on the lesson operations
This excerpt omits shared lab setup. Use the complete download and supporting files to run it.
Dim cmd, changed
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
cmd.CommandText = "INSERT INTO Workshops (Id, Label, Seats) VALUES (?, ?, ?)"
cmd.Parameters.Append cmd.CreateParameter("id", 3, 1, , 4)
cmd.Parameters.Append cmd.CreateParameter("label", 202, 1, 60, "Darners' circle")
cmd.Parameters.Append cmd.CreateParameter("seats", 3, 1, , 2)
cmd.Execute changed, , 128
Response.Write "Inserted: " & changed & vbLf
Response.Write cn.Execute("SELECT Label FROM Workshops WHERE Id=4")(0)
Set cmd = Nothing
Expected result
Inserted: 1 Darners' circle
Option 128 is adExecuteNoRecords. The affected count and fetched label are both checked; a message alone would not prove the apostrophe survived. The primary key rejects a duplicate identifier instead of overwriting it.