Presentation is loading. Please wait.

Presentation is loading. Please wait.

Labtest.ASP Notes. INSERT STATUS <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %> INSERT STATUS <% mydsn=

Similar presentations


Presentation on theme: "Labtest.ASP Notes. INSERT STATUS <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %> INSERT STATUS <% mydsn="— Presentation transcript:

1 Labtest.ASP Notes

2 INSERT STATUS <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %> INSERT STATUS <% 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 FirstName LastName Netid (Required for all operations) Favorite Quote Insert data Update data Delete this person Find this person <% 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 " INSERT Statement: " & sql & " " ' 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 %> <% ' close the connection down conn.close conn="" %>

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?


Download ppt "Labtest.ASP Notes. INSERT STATUS <% mydsn= "websysx" Set conn = Server.CreateObject("ADODB.Connection") conn.open mydsn,"","" %> INSERT STATUS <% mydsn="

Similar presentations


Ads by Google