<%@ 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 %>