1 / 12

Labtest.ASP Notes

Labtest.ASP Notes. <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=windows-1252"> <TITLE>INSERT STATUS</TITLE> </HEAD> <BODY> <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %>. <HTML> <HEAD>

dory
Download Presentation

Labtest.ASP Notes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Labtest.ASP Notes

  2. <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=windows-1252"> <TITLE>INSERT STATUS</TITLE> </HEAD> <BODY> <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=windows-1252"> <TITLE>INSERT STATUS</TITLE> </HEAD> <BODY> <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %>

  3. <% ' retrieve values from form (GET) 2 text fields ' Note we need to put them in quotes for the insert statement ' & is the VB concatentation character ' get the values FirstName =Request.QueryString("FirstName") LastName =Request.QueryString("LastName") Netid =Request.QueryString("Netid") Quote =Request.QueryString("Quote") Operation =Request.QueryString("Operation") Doform =Request.QueryString("Doform")

  4. if Doform <> "False" then %> Use this form to insert, update, delete and query the data base<p> <form name="labtest" action="labtest.asp" method="GET"> <input type="text" name="FirstName" size="30"> FirstName <p> <input type="text" name="LastName" size = "30" > LastName <p> <input type="text" name="Netid" size="8"> Netid (Required for all operations)<p> <textarea name= "Quote" rows="4" cols="60"> </textarea> Favorite Quote<p> <input type="radio" name="Operation" value="Insert"> Insert data <p> <input type="radio" name="Operation" value="Update"> Update data <p> <input type="radio" name="Operation" value="Delete"> Delete this person <p> <input type="radio" name="Operation" value="Query"> Find this person <p> <input type="hidden" name="Doform" value="False""> <input type="submit" value="submit"> </form> <% End If

  5. If Doform = "False" then If Operation = "Insert" then 'SQL INSERT SYNTAX: 'INSERT INTO table_name (column1, column2,...) 'VALUES (value1, value2,....) ' BE CAREFUL numeric fields are not quoted, text fields are ' ' Create the insert statement sql = "INSERT into labtest (FirstName, LastName, Netid, Quote) " sql = sql & "VALUES(" & "'" & FirstName & "'" & "," sql = sql & "'" & LastName & "'" & "," sql = sql & "'" & Netid & "'" & "," sql = sql & "'" & Quote & "')"

  6. ' write the insert statement out for debugging response.write "<p>INSERT Statement: " & sql & "<P>" ' execute the insert statement Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, conn, 3, 3 Else response.write "Currently only Insert Operations are supported" End If End If %> <% ' close the connection down conn.close conn="" %> </BODY>

  7. Some Problems How do I add the new functions? How do I do error checking? • Update – • What is the easiest way to allow the user to change a record. • Delete – • How can I allow a user to delete multiple records at a time • How do I minimize errors? • Query • How does the user specify the query? • What are some options they might want? • Can I pass (link) the results of a query to another operation?

  8. New Functions • IF Operation =“DELETE” then • Sql = “DELETE ROW from labtest where Netid=‘” & Netid & “’” • Set rs = Server.CreateObject("ADODB.Recordset") • rs.Open sql, conn, 3, 3 • END IF

  9. Error Checking • The Result code of the Open statement returns error status • The result set has properties that can be checked by Visual Basic

  10. Update Possibilities • 1) User specifies all fields • 2) User just supplies netid, and a new form is generated with the fields already filled out with existing information • 3) User supplies a query, all records satisfying query are returned with fields filled out, user makes changes and resubmits all of the record at once.

  11. Delete Options • 1) User supplies netid and indicates DELETE • 2) User is provided with a list of all netids and then can delete those they wish. (problems??) • 3) User supplies a query, results of query generate a form where user can delete any items.

  12. Other problems • What if user wants to insert a “special” character in their Quote. • What characters could be a problem? Why? What can you do?

More Related