ASP-14-1 Advanced ASP Techniques Colorado Technical University IT420 Tim Peterson
ASP-14-2 Command Object ADO provides the Command object which is specifically designed to run commands against a data store. Creation of the Command object is as follows: Set objCommand = Server.CreateObject(“ADODB.Command”)
ASP-14-3 Command Object Execution To execute a command, we use it’s execute method: objCommand.Execute RecordsAffected, Parameters, Options RecordsAffected - This parameter is for action queries. Parameters - Holds an array of parameters passed to the command. Options - similar to the options parameter we used for the recordset object. Defines the type of command being run.
ASP-14-4 Parameter creation Parameter creation syntax is: Set objRS = objComm.CreateParameter(Name, Type, Direction, Size, Value) Name - Specifies the name of the parameter Type - Defines the data type of the parameter. Direction - Parameters can either be used to send or return data. Size - Specifies that maximum length of the parameter in length of char string of bytes. Value - Can be used to initialize the parameter (constant).
ASP-14-5 Specifying Parameter Properties Set objParam = objComm.CreateParameter objParam.Name = “Director” objParam.Type = adVarChar objParam.Size = 50 objParam.Direction = adInput objParam.Value = “Time for beer”
ASP-14-6 Distributed Author Versioning IIS 5.0 is referred to as WEBDAV and uses extensions of HTTP 1.1 protocol. Allows client software to manipulate server files. WEBDAV then allows for distributed authoring of documents on the Web. WEBDAV can also be used for s or any other form of data store for which there is an OLE-DB provider.
ASP-14-7 WEBDAV Objects WEBDAV provides two additional objects that come with ADO 2.5 –Record Object - used to represent a record in a recordset. –Stream Object - represents data in either binary or plain text.
ASP-14-8 Semi-Structured Data NODE CHILDREN
ASP-14-9 Viewing Record Properties Retrieving Semi-structured Data <% Dim objNodeRecord, objNodeField Set objNodeRecord = Server.CreateObject("ADODB.Record") objNodeRecord.Open "","URL= Response.Write " Properties of the folder: " Response.Write " " For Each objNodeField in objNodeRecord.Fields Response.Write " " & _ " " & objNodeField.Name & " " & _ " " & objNodeField.Value & " " & _ " " Next Response.Write " " objNodeRecord.Close Set objNodeRecord = Nothing %>
ASP Record Object Methods There are three methods that can be used: –CopyRecord objRecord.Open “File.txt”, “URL= objRecord.CopyRecord “ “, “ –MoveRecord objRecord.Open “File.txt”, “URL= objRecord.MoveRecord “ “, “ –DeleteRecord objRecord.Open “File.txt”, “URL= objRecord.DeleteRecord
ASP Stream Object This object allows us to access data contained within the Record object. To create a stream object: Set objStream = Server.CreateObject(“ADODB.Stream”) Open Method for the Stream object is as follows: objStream.Open Source, ModeofAccess, OpenOptions, UserId, Password
ASP Stream Object Parameters Source - URL of the file we want to access ModeofAccess - adModeRead (read only) or adModeReadWrite (read/write access) OpenOptions - specifies where we are getting the data from –adOpenStreamFromURL - Get data from a URL source. –adOpenStreamFromRecord - Get data from an existing Record object.
ASP Stream Object - Additional Methods ReadText Method: objStream.Charset = “Ascii” Response.Write (objStream.ReadText) WriteText Method: objStream.Position = 0 strText “This is the last slide. Now write in the stream” objStream.WriteText(strText)