Assembly Builder Generated Code for NorthWind.BL Sample |
|
Customer.vb |
Public Class Customer
#Region " Private Properties "
Private Shared CONNECTION_STRING As String
Private ReadOnly Property ConnectionString() As String
Get
If CONNECTION_STRING Is Nothing Then
Try
CONNECTION_STRING = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings(Me.GetType().FullName + ".ConnectionString"))
If CONNECTION_STRING = "" Or CONNECTION_STRING Is Nothing Then
Throw New Exception("No connection string")
End If
Catch ex As Exception
Throw New Exception("Connection string not configured")
End Try
End If
Return CONNECTION_STRING
End Get
End Property
#End Region
Public Function GetOrderHistory(ByVal CustomerID As String) As DataSet
Dim cnDB As New SqlClient.SqlConnection(ConnectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open()
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.CustOrderHist"
Dim p As SqlClient.SqlParameter
p = New SqlClient.SqlParameter
p.ParameterName = "@CustomerID"
p.SqlDbType = SqlDbType.VarChar
p.Direction = ParameterDirection.Input
p.Value = CustomerID
cmDB.Parameters.Add(p)
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter
daDataSQL.SelectCommand = cmDB
dsData = New DataSet
daDataSQL.Fill(dsData, "CustOrderHist")
cnDB.Close()
Return dsData
End Function
Public Function GetOrders(ByVal CustomerID As String) As DataSet
Dim cnDB As New SqlClient.SqlConnection(ConnectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open()
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.CustOrdersOrders"
Dim p As SqlClient.SqlParameter
p = New SqlClient.SqlParameter
p.ParameterName = "@CustomerID"
p.SqlDbType = SqlDbType.VarChar
p.Direction = ParameterDirection.Input
p.Value = CustomerID
cmDB.Parameters.Add(p)
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter
daDataSQL.SelectCommand = cmDB
dsData = New DataSet
daDataSQL.Fill(dsData, "CustOrdersOrders")
cnDB.Close()
Return dsData
End Function
Public Function GetOrderDetails(ByVal OrderID As Integer) As DataSet
Dim cnDB As New SqlClient.SqlConnection(ConnectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open()
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.CustOrdersDetail"
Dim p As SqlClient.SqlParameter
p = New SqlClient.SqlParameter
p.ParameterName = "@OrderID"
p.SqlDbType = SqlDbType.Int
p.Direction = ParameterDirection.Input
p.Value = OrderID
cmDB.Parameters.Add(p)
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter
daDataSQL.SelectCommand = cmDB
dsData = New DataSet
daDataSQL.Fill(dsData, "CustOrdersDetail")
cnDB.Close()
Return dsData
End Function
End Class |
|
Products.vb |
Public Class Products
#Region " Private Properties "
Private Shared CONNECTION_STRING As String
Private ReadOnly Property ConnectionString() As String
Get
If CONNECTION_STRING Is Nothing Then
Try
CONNECTION_STRING = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings(Me.GetType().FullName + ".ConnectionString"))
If CONNECTION_STRING = "" Or CONNECTION_STRING Is Nothing Then
Throw New Exception("No connection string")
End If
Catch ex As Exception
Throw New Exception("Connection string not configured")
End Try
End If
Return CONNECTION_STRING
End Get
End Property
#End Region
Public Function GetTenMostExpensive() As DataSet
Dim cnDB As New SqlClient.SqlConnection(connectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.Ten Most Expensive Products"
Dim p As SqlClient.SqlParameter
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter()
daDataSQL.SelectCommand = cmDB
dsData = New DataSet()
daDataSQL.Fill(dsData, "Ten Most Expensive Products")
cnDB.Close()
Return dsData
End Function
End Class
|
|
Sales.vb |
Public Class Sales
#Region " Private Properties "
Private Shared CONNECTION_STRING As String
Private ReadOnly Property ConnectionString() As String
Get
If CONNECTION_STRING Is Nothing Then
Try
CONNECTION_STRING = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings(Me.GetType().FullName + ".ConnectionString"))
If CONNECTION_STRING = "" Or CONNECTION_STRING Is Nothing Then
Throw New Exception("No connection string")
End If
Catch ex As Exception
Throw New Exception("Connection string not configured")
End Try
End If
Return CONNECTION_STRING
End Get
End Property
#End Region
Public Function GetByYear(ByVal Beginning_Date As Date, ByVal Ending_Date As Date) As DataSet
Dim cnDB As New SqlClient.SqlConnection(ConnectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open()
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.Sales by Year"
Dim p As SqlClient.SqlParameter
p = New SqlClient.SqlParameter
p.ParameterName = "@Beginning_Date"
p.SqlDbType = SqlDbType.DateTime
p.Direction = ParameterDirection.Input
p.Value = Beginning_Date
cmDB.Parameters.Add(p)
p = New SqlClient.SqlParameter
p.ParameterName = "@Ending_Date"
p.SqlDbType = SqlDbType.DateTime
p.Direction = ParameterDirection.Input
p.Value = Ending_Date
cmDB.Parameters.Add(p)
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter
daDataSQL.SelectCommand = cmDB
dsData = New DataSet
daDataSQL.Fill(dsData, "Sales by Year")
cnDB.Close()
Return dsData
End Function
Public Function GetByCategory(ByVal CategoryName As String, ByVal OrdYear As String) As DataSet
Dim cnDB As New SqlClient.SqlConnection(ConnectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open()
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.SalesByCategory"
Dim p As SqlClient.SqlParameter
p = New SqlClient.SqlParameter
p.ParameterName = "@CategoryName"
p.SqlDbType = SqlDbType.VarChar
p.Direction = ParameterDirection.Input
p.Value = CategoryName
cmDB.Parameters.Add(p)
p = New SqlClient.SqlParameter
p.ParameterName = "@OrdYear"
p.SqlDbType = SqlDbType.VarChar
p.Direction = ParameterDirection.Input
p.Value = OrdYear
cmDB.Parameters.Add(p)
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter
daDataSQL.SelectCommand = cmDB
dsData = New DataSet
daDataSQL.Fill(dsData, "SalesByCategory")
cnDB.Close()
Return dsData
End Function
Public Function GetEmployeesByCountry(ByVal Beginning_Date As Date, ByVal Ending_Date As Date) As DataSet
Dim cnDB As New SqlClient.SqlConnection(ConnectionString)
Dim cmDB As New SqlClient.SqlCommand
cnDB.Open()
cmDB.Connection = cnDB
cmDB.CommandType = CommandType.StoredProcedure
cmDB.CommandText = "dbo.Employee Sales by Country"
Dim p As SqlClient.SqlParameter
p = New SqlClient.SqlParameter
p.ParameterName = "@Beginning_Date"
p.SqlDbType = SqlDbType.DateTime
p.Direction = ParameterDirection.Input
p.Value = Beginning_Date
cmDB.Parameters.Add(p)
p = New SqlClient.SqlParameter
p.ParameterName = "@Ending_Date"
p.SqlDbType = SqlDbType.DateTime
p.Direction = ParameterDirection.Input
p.Value = Ending_Date
cmDB.Parameters.Add(p)
Dim daDataSQL As SqlClient.SqlDataAdapter
Dim dsData As DataSet
daDataSQL = New SqlClient.SqlDataAdapter
daDataSQL.SelectCommand = cmDB
dsData = New DataSet
daDataSQL.Fill(dsData, "Employee Sales by Country")
cnDB.Close()
Return dsData
End Function
End Class
|
|
NorthWind.BL.vbproj |
<VisualStudioProject>
<VisualBasic
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{3ab36c78-2a4a-4843-a5f5-cc09a3ad6ff6}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "NorthWind.BL"
AssemblyOriginatorKeyFile = ""
AssemblyOriginatorKeyMode = "None"
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
OptionCompare = "Binary"
OptionExplicit = "On"
OptionStrict = "Off"
RootNamespace = "NorthWind.BL"
StartupObject = ""
>
<Config
Name = "Debug"
BaseAddress = "285212672"
ConfigurationOverrideFile = ""
DefineConstants = ""
DefineDebug = "true"
DefineTrace = "true"
DebugSymbols = "true"
IncrementalBuild = "true"
Optimize = "false"
OutputPath = "bin\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "1"
/>
<Config
Name = "Release"
BaseAddress = "285212672"
ConfigurationOverrideFile = ""
DefineConstants = ""
DefineDebug = "false"
DefineTrace = "true"
DebugSymbols = "false"
IncrementalBuild = "false"
Optimize = "true"
OutputPath = "bin\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "1"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
/>
</References>
<Imports>
<Import Namespace = "Microsoft.VisualBasic" />
<Import Namespace = "System" />
<Import Namespace = "System.Collections" />
<Import Namespace = "System.Data" />
<Import Namespace = "System.Diagnostics" />
</Imports>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.vb"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Customer.vb"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Sales.vb"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Products.vb"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</VisualBasic>
</VisualStudioProject>
|
Last Updated: 21 July 2004 |