Data transfer happens in one of two directions: either retrieving it from the database to display in an HMTL page, or sending it to the database. Retrieving [] By far, the easiest. The code in the previous lecture already shows you how to open a ResultSet. All you need to do now is get the data. This is done with the getString(), and works in the same manner as the getParameter() method of the request object. You may do it either inside a code block by assigning the value stored in the field to a variable or as in-line code. The following examples demonstrate both methods: [] Sending [][] Formatting the data to appear nicely in HTML works the same in JSP as it does in ASP. Review the following source code for the Addresses example from Module 3: [] <% firstName = rst.getString("firstName") %> <%= rst.getString("firstName") %> [][] View List View Detail Edit Detail [] [] Sending data also works about the same in JSP as it does in ASP. The query needs to be created as a String, then use the executeUpdate() method of the Statement object: [] [] []][] rowsAffected is a variable that will store the number of record affected by the update. If I am adding a record, changing a record, or deleting a record, I would expect this value to be 1. If I delete 10, records, the value would be 10 if all records were successfully deleted. You know how many records should be affected. Always compare this variable against that value to make sure the update succeeded. The main problem is, there is no easy way to get a count of the number of fields passed, as we can in ASP. So, I've added a hidded field to the ViewDetail and EditDetail forms that indicate what the next step in the process is to be. The UpdateDetail page will test the value so it knows what steps to take. For the Delete button on the ViewDetail page, I've added the field to the query string. Take a close look at []Update Detail[]. [] rowsAffected = stm.executeUpdate(strSQL); [][] For an INSERT query, the format for the SQL is: [] DELETE FROM Table Note that the AddressID field is used in the WHERE clause. This ensures that just the one record is deleted. [] INSERT INTO Table(Comma-separated field list) VALUES(Comm-separate value list) The For loop in the code creates the two lists as variable strings. Once the loop is complete, the string variables are concatenated with the rest of the SQL. Note that the AddressID field is ignored, since this is an auto-number field. [] For an UPDATE query, the format for the SQL is: [] UPDATE Table SET] For a DELETE query, the format for the SQL is: [The For loop creates the list as a variable string. Once the loop is complete, the string variable is concatenated with the rest of the SQL. Note that the AddressID field is used in the WHERE clause. This ensures that just the one record is updated. [