Autodesk 15606-011408-9300 Developer Guide - Page 112
Specifying a Scripting Language, Selecting Database Records, Parcel_Data, Assessor, <CFQUERY>
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 112 highlights
Specifying a Scripting Language ASP scripts are written in VBScript, a lightweight Visual Basic-like scripting language, or in JScript, the Microsoft version of JavaScript. ASP files should begin with a line telling ASP which language you're using (although a default of VBScript is assumed if the line is omitted). Since we're using VBScript, our line will look like this: Note the use of , which identify the line as the server-side code that ASP should process. Selecting Database Records Next, we'll add a some code to define a selected set of database records. This selection is known as a recordset. To come up with a recordset, we need to know which database table to connect to, and which records to select from that table. If your map links to a table called Parcel_Data through an OLE DB data source called Assessor, the recordset code will look like this: This might seem complicated compared to ColdFusion's tag, but it will look familiar to Visual Basic programmers. The end result is a Recordset object variable, RS, which represents all houses in Parcel_Data that have a Year_Built value of 1963. Note Don't be put off by this code if you are unfamiliar with Visual Basic. All of your ASP database queries will follow this basic format, with only the DSN and SQL statement varying. Let's go through the recordset script line by line. The first line of code uses the CreateObject method of the Server object to create a new Connection object, which is assigned to the dbConnection variable. Set dbConnection = Server.CreateObject("ADODB.Connection") The next line opens a connection to the data source name (DSN), in this case Assessor, and assigns that connection to the dbConnection variable. Note that Open is a method of the Connection object, in this case the dbConnection variable. dbConnection.Open("Assessor") 112 | Chapter 6 Using Reports to Query and Update Data Sources