A Wrapper Class for the SQL Server Based Data Access Helper - Adding miscellaneous wrapper methods
(Page 7 of 7 )
The following is the wrapper method used to get the next value in a sequence:
Public Function getNextSequence(ByVal ParamName As String, Optional ByVal TableName As String = "SysParams") As String
Try
ObjLib = getDBHelperObject()
Return ObjLib.getNextSequence(ParamName, TableName)
Catch ex As Exception
Throw ex
Finally
Try
System.EnterpriseServices.ServicedComponent.DisposeObject(ObjLib)
Catch ex As Exception
End Try
End Try
End Function
The following is the wrapper method used to retrieve a BLOB value from the database:
Public Sub getBLOBValue(ByVal sqlSELECT As String, ByRef BinData() As Byte)
Try
ObjLib = getDBHelperObject()
ObjLib.getBLOBValue(sqlSELECT, BinData) 'it contains reference parameter, so nothing to return back
Catch ex As Exception
Throw ex
Finally
Try
System.EnterpriseServices.ServicedComponent.DisposeObject(ObjLib)
Catch ex As Exception
End Try
End Try
End Sub
Adding SQL Server stored procedure parameter support to the wrapper
As the parameters of a stored procedure would be a bit different for every database, I started developing a different class especially for SQL Server by extending the same from the above wrapper class.
The class definition would look something like the following:
PublicClass MSSQLDBLib
Inherits DBLib
To work with data types, I include the following enumeration:
PublicEnum MSSQLDataType
SQLString
SQLChar
SQLInteger
SQLBit
SQLDateTime
SQLDecimal
SQLMoney
SQLImage
SQLFloat
EndEnum
I also included the following members to work with stored procedures:
Private dtParameterList As New DataTable
Private arParameterList As New ArrayList
The source code for MSSQLDBLib is included as part of the download. You can download it and use it for yourself.
The entire series was created only for understanding the development of data helpers with object orientation. Before trying to use this data helper in your applications, I request that you go through the Microsoft Data Access Blocks, which include several features.
Any feedback, suggestions, bugs, errors, improvements etc., are highly appreciated at jag_chat@yahoo.com.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |