Geeks With Blogs
Brian Scarbeau Insights from a seasoned Computer Science Trainer

In class today we reviewed the test that the students took before the Thanksgiving break. It was on chapters 7-9. I think my students were thinking more about the vacation than they were my test because the class average was a 76 which was ok but I know that my class could have done better.

Students are working on Lesson 12 with Webmatrix and continuing to work with the Code Wizards that comes with the software. They will create a Band Journal Page where fans will be able to browse through the journal entries made by the band members. They will get the journal information from the database and display it using a DataGrid.

They will learn to use the Select command:

SELECT * FROM [Artists]
SELECT [ArtistJournal].Date, [ArtistJournal].IDNumber FROM [ArtistJournal]
They will learn about the  WHERE clause to a SELECT statement to limit (filter) which records are returned.
Use a radiobutton:
Sub RadioButtonList1_SelectedIndexChanged(sender As Object, e As EventArgs)
    Dim rbChoice as integer
    rbChoice = CInt(radiobuttonlist1.selecteditem.value)
End Sub











Use the order by clause:

Adding the ORDER BY Clause

Often your dataset will return records that are not in a particularly useful order. Maybe you want to order the BandJournal records alphabetically by Remarks. In SQL, the ORDER BY clause is used to sort the records in a specific order. The Code Wizard does not offer an ORDER BY clause. We can add this by "code tweaking". Here's how:

  1. In the Code window, find the SELECT clause in the Function QM_ArtistJournal_IDDate(ByVal iDNumber As Integer, ByVal [date] As Date) As System.Data.DataSet.
  2. Change the code in Function QM_ArtistJournal_IDDate(ByVal iDNumber from:

    Dim queryString As String = "SELECT [ArtistJournal].IDNumber, [ArtistJournal].Date FROM [ArtistJournal] WHERE (([ArtistJournal].[IDNumber] "& _" = @IDNumber) AND ([ArtistJournal].[Date] > @Date))"


    Dim queryString As String = "SELECT [ArtistJournal].* FROM [ArtistJournal] WHERE (([ArtistJournal].[IDNumber] "&_" = @IDNumber) AND ([ArtistJournal].[Date] > @Date)) " & _" ORDER BY [ArtistJournal].[Remarks] DESC"

    There's a great deal of sql commands to review in the chapter. However, the code wizard does make it easy for students to follow and the examples given in the lesson are excellent. As the teacher, make sure you walk through an example and discuss everything that is happening when the students create the query for the lesson.

The next lesson will review the Insert and Delete Code wizards.

Posted on Monday, November 28, 2005 9:37 AM Teaching with ASP.NET | Back to top

Copyright © Brian Scarbeau | Powered by: