Đang chuẩn bị liên kết để tải về tài liệu:
Visual Basic .NET at Work Building 10 Enterprise Projects phần 4
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Gõ vào một tên cho biểu mẫu và sau đó nhấn Open. Trên cửa sổ tiếp theo, như trong hình 1,11, lựa chọn hình thức mà bạn muốn kế thừa. Lựa chọn hình thức frmBase và nhấn OK. Bây giờ bạn có một hình thức di truyền trong chương trình của bạn. | 134 Project 4 sWhere AND RTRIM FunctionName sFunction . Else sWhere WHERE RTRIM FunctionName sFunction . End If End If Tack on the where clause. sSQL sWhere Load the data. Try Dim da As New SqlDataAdapter sSQL CONNSTR conn.Open da.Fill ds perfdata conn.Close Catch ex As SqlException conn.Close Throw ex End Try Return ds End Function If a beginning date is supplied we will only retrieve data later than that date. If an end date is supplied we only retrieve data earlier than that date. If a username is supplied only records that match that username will be retrieved. The same goes for the FunctionName. The bulk of the GetPerfData method is dedicated to building the WHERE clause based on these parameters. Once the WHERE clause is constructed we simply retrieve the data using a DataAdapter. Lastly we return the DataSet to the caller. Remember that DataSets are derived from MarshalByValueObject and this can be serialized for Remoting. The code for the Analysis is more complex but works well. We will be calculating Minimum Maximum and Average values for all the data by FunctionName. Therefore we need to get data back from the database by function name for all the function names. There are two steps in this process. First we load a list of unique function names that currently reside in the database. Second this list is used to load performance data for each function name that we just loaded. Take a look at the code then we ll talk. Public Function BasicStats As DataSet Dim conn As New SqlConnection CONNSTR Dim dsFunctions As New DataSet Holds returned functions Dim dsData As New DataSet Holds all data for a function Dim dsStats As New DataSet Our return DataSet Dim sSQL As String Performance Testing with Remoting 135 Dim sWhere As String Dim cmd As New SqlCommand Get the list of functions we need to process. sSQL SELECT DISTINCT FunctionName FROM PerfData Dim da As New SqlDataAdapter sSQL CONNSTR Try conn.Open da.Fill dsFunctions functions Catch ex As SqlException .