






Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
apostila asp
Tipologia: Notas de estudo
1 / 10
Esta página não é visível na pré-visualização
Não perca as partes importantes!







The basic network architecture of the Price College of Business comprises of computers and other components (printers, scanners, routers, etc) connected to each other. Each component communicates with the network via a TCP/IP Ethernet connection.
The servers of the network run on Windows 2000 operating systems based on NT technology. These servers allow users to access various resources ranging from web pages to lecture slides.
A client is defined as the computer (network component) that request services from another computer/component. These services include retrieving files and performing other network activities.
A server, on the other hand, can be defined as a computer or software on the network that provides these services to the components requesting them.
It is important to understand that on a network, a single machine can be both – a client and a server at the same time!
In order to understand how exactly the client server mechanism works let us consider the following illustration.
User requests information
According to this diagram, a user requests information through his/her computer. This is done using the web browser software that resides on the computer. The user in this case is a client (requesting information). This requested information gets forwarded on to the web server. All database related requests get sent to the database server. Once these queries have been processed, the results are sent back to the web server which in turn sends it back to the computer and finally to the user.
The ASP implementation consists of two files – one HTML file to input the database query, and an ASP file to process this query and display the executed output.
Note: any webpage editing tool such as Macromedia Dreamweaver, Microsoft FrontPage, or even notepad can create HTML and ASP files. This tutorial assumes the reader will be using notepad for creating the HTML file.
Enter your query here:
Explanation of the HTML code:
Step 6: Open up the main HTML tags first. **** and ****. Your main HTML code will come between these two tags.
Step 7: Now open up the and tags. Within these tags write open up the title tags also. and . Whatever is entered within the title tags will appear on the top of your browser. In this case type in Query Page.
Step 8: After the tags open up the tags. This will contain what actually appears on your browser. In our case we would also like to give our HTML page a background color. Hence when you open up the body tag also type in the background color in this manner:
Step 9: in order to write something on top of the page you should type in the following HTML statement: Query Form Page :
Through this statement we are saying that the font should be Arial black, the color of the font should be white and the font size should be 6. Within the actual tags we specify what we really need to be displayed. Hence we type in “Query form page: “ Always make sure you close the tags once you’re done with it.
Step 10: The tag is to provide spacing. Hence type in a few times (depending on how much space you want between the “Query form page:” and the query box). This is one tag that does not have a closing tag.
Step 11: Now we to set up a box to accept your query. The following tag should be typed. < form action= “executequery.asp” method = “POST”> This tag activates the asp file
Step 12: Once again we need to display a sentence. Hence enter the following tag. < p align= “centre”>Enter your query here: Here also we mainly specify the font type, color and font size. Be sure to close your tags.
Step 5: Save the file and close notepad.
Step 6: Open your internet browser (Internet Explorer, Netscape, etc). Click on File , and then click Open. A pop-up box appears. To locate the HTML file we just created, click on Browse to search for the file. Double-click the file and click Ok. Your query page should now load and look something like this:
Step 7: Open Notepad once again, and create a new File called “executequery.asp”. ( The entire ASP code is given toward the end of the Explanation (Page 11) )
Step 8: We start off by giving the page a title and opening the script tags. These tags are represented by the <% and %> signs. A screenshot of what the file should look like is provided below.
Step 9: Next, we need to get the query (typed by the user) from the textbox in the HTML page. We do this by using the Request.Form() command. This accepts the name of the component we wish to extract the information from. Recall, in the HTML file, we named the textbox QUERYBOX, and so the command would be:
Request.Form("QUERYBOX")
The value that we receive should be saved locally in the ASP file. To do this, we declare a variable and assign it this value. The Dim command is used to declare ASP variables. A screenshot of this code is provided below:
Step 13: Once the connection has been established we need to create an command line for the database that accepts the query. In order to do this, we need to type in the following code:
We start off by creating the command object that will accept the query. Dim objCommand Set objCommand = Server.CreateObject(“ADODB.Command”)
After this, we need to ensure that the command object created is pointing to the database connection we created in Step 12: objCommand.ActiveConnection = strConnect
Once this is done, we actually pass the query that we obtained earlier on (and stored in the query variable in Step 9): objCommand.CommandText = query objCommand.CommandType = 1
Finally, we create the Resultset object that is needed to store the results received from the database. Set objRS = objCommand.Execute
Your file should now look like this:
Step 14: The rest of the code is to construct the results page in a tabular form. The objRS.EOF command is used to ensure that all the results are read and displayed in the table. The code for this is as follows:
Dim strT, fldF If objRS.EOF Then Response.Write "No Results for the query"
Else strT = " " For Each fldF In objRS.Fields strT = strT & "" & fldF.Name & "" Next strT = strT & ""
While Not objRS.EOF strT = strT & "" For Each fldF In objRS.Fields strT = strT & "" & fldF.Value & "" Next strT = strT & "" objRS.MoveNext Wend
strT = strT & "" Response.Write strT & "" End If
*Screen shot for this section is included in the next step
Step 15: Finally, we set objRS and objCommand to “Nothing” to clear their current values. Set objRS = Nothing Set objCommand = Nothing
Full code on the next page
Step 16: The completed ASP file should look like this:
Query Result
Dim query query = Request.Form("QUERYBOX")
Response.Write "The Query : " & query & ""
Dim strConnect
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("wompom.mdb")
objRS Dim objCommand, Set objCommand = Server.CreateObject("ADODB.Command")
Your group folder can only be accessed by members of your group.
Upload your access database, HTML and ASP files in your Group folder.
Step 17: Once this is done, open your web browser and type in the following address: http://pcbstudents.ou.edu/tcarte/group#/query.html
In Place of the group# replace it with the group number given to you by your professor. Hence if you are Group11 the web address will be:
http://pcbstudents.ou.edu/tcarte/group11/query.html You will see the HTML page that you had created. Go ahead and type in a query and hit the “Execute Query’ button.
And the results: