' <fileinfo name="Northwind.vb">
' <copyright>
' All rights reserved.
' </copyright>
' <remarks>
' You can update this source code manually. If the file
' already exists it will not be rewritten by the generator.
' </remarks>
' <generator rewritefile="False" infourl="http://www.SharpPower.com">RapTier</generator>
' </fileinfo>
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
''' <summary>
''' Represents a connection to the <c>Northwind</c> database.
''' </summary>
''' <remarks>
''' If the <c>Northwind</c> goes out of scope, the connection to the
''' database is not closed automatically. Therefore, you must explicitly close the
''' connection by calling the <c>Close</c> or <c>Dispose</c> method.
''' </remarks>
''' <example>
''' using(Northwind db = new Northwind())
''' {
''' AlphabeticallistofproductsRow[] rows = db.AlphabeticallistofproductsView.GetAll();
''' }
''' </example>
Public Class Northwind
Inherits Northwind_Base
''' <summary>
''' Initializes a new instance of the <see cref="Northwind"/> class.
''' </summary>
Public Sub New()
MyBase.New()
' EMPTY
End Sub
''' <summary>
''' Creates a new connection to the database.
''' </summary>
''' <returns>An <see cref="System.Data.IDbConnection"/> object.</returns>
Protected Overrides Function CreateConnection() As IDbConnection
#If ODBC Then
Return new Microsoft.Data.Odbc.OdbcConnection("INSERT ODBC CONNECTION STRING")
#ElseIf SQL_CLIENT Then
Return New System.Data.SqlClient.SqlConnection( _
"Integrated Security=SSPI;Initial Catalog=Northwind")
#Else
Return New System.Data.OleDb.OleDbConnection( _
"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=Fa" + _
"lse;Initial Catalog=Northwind")
#End If
End Function
''' <summary>
''' Creates a DataTable object for the specified command.
''' </summary>
''' <param name="command">The <see cref="System.Data.IDbCommand"/> object.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Protected Friend Function CreateDataTable(command As IDbCommand) As DataTable
Dim dataTable As DataTable = New DataTable()
Dim dataAdapter As System.Data.Common.DbDataAdapter
#If ODBC Then
dataAdapter = New System.Data.Odbc.OdbcDataAdapter(CType(command, System.Data.Odbc.OdbcCommand))
#ElseIf SQL_CLIENT Then
dataAdapter = New System.Data.SqlClient.SqlDataAdapter(CType(command, System.Data.SqlClient.SqlCommand))
#Else
dataAdapter = New System.Data.OleDb.OleDbDataAdapter(CType(command, System.Data.OleDb.OleDbCommand))
#End If
dataAdapter.Fill(dataTable)
Return dataTable
End Function
''' <summary>
''' Returns a SQL statement parameter name that is specific for the data provider.
''' For example it returns ? for OleDb provider, or @paramName for MS SQL provider.
''' </summary>
''' <param name="paramName">The data provider neutral SQL parameter name.</param>
''' <returns>The SQL statement parameter name.</returns>
Protected Friend Overrides Function CreateSqlParameterName(paramName As String) As String
#If ODBC Then
Return "?"
#ElseIf SQL_CLIENT Then
Return "@" + paramName
#Else
Return "?"
#End If
End Function
''' <summary>
''' Creates a .Net data provider specific parameter name that is used to
''' create a parameter object and add it to the parameter collection of
''' <see cref="System.Data.IDbCommand"/>.
''' </summary>
''' <param name="baseParamName">The base name of the parameter.</param>
''' <returns>The full data provider specific parameter name.</returns>
Protected Overrides Function CreateCollectionParameterName(baseParamName As String) As String
#If ODBC Then
Return "@" + baseParamName
#Else
Return "@" + baseParamName
#End If
End Function
End Class