To use this code, you'll need to download and install System.Data.SQLite first. Create a new class library project called "DMFL.Data.SQLite.DAL", create a vb file and paste the code below into it. Ensure that your base namespace is empty! All the classes needed for the DAL are present in one file - you can split them up if you like (and I'll try to find the time to make the source available as a download soon). You'll need references to System, System.Data and System.Data.SQLite. That's all you need - enjoy!
Option Explicit On
Option Strict On
Imports DMFL.Data.SQLite.DAL.Exceptions
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Data.SQLite
Namespace DMFL.Data.SQLite.DAL
''' <summary>
''' Provides data connection functionality to all of the Helper classes in this Namespace.
''' </summary>
Public MustInherit Class HelperBase
#Region " Properties "
Private c_strConnectionString As String = String.Empty
''' <summary>
''' Gets/sets the ConnectionString.
''' </summary>
''' <value>A String object.</value>
''' <returns>A String object.</returns>
''' <remarks></remarks>
Public Property ConnectionString() As String
Get
Return c_strConnectionString
End Get
Set(ByVal value As String)
c_strConnectionString = value
End Set
End Property
Private c_mscConnection As SQLiteConnection
''' <summary>
''' The SQLiteConnection used by derived Classes to access the data.
''' </summary>
''' <value>A SQLiteConnection object.</value>
''' <returns>A SQLiteConnection object.</returns>
Public Property Connection() As SQLiteConnection
Get
Return c_mscConnection
End Get
Set(ByVal value As SQLiteConnection)
c_mscConnection = value
End Set
End Property
#End Region
#Region " Constructors "
''' <summary>
''' Sets custom connection information when the Class is instantiated.
''' </summary>
''' <param name="strConnectionString">A connection string</param>
''' <remarks></remarks>
''' <exception cref="UnhandledException">This exception is thrown
''' if the constructor fails for any reason.</exception>
Protected Sub New(ByVal strConnectionString As String)
Try
ConnectionString = strConnectionString
Catch ex As Exception
Throw New UnhandledException(ex)
End Try
End Sub
''' <summary>
''' Provides a SQLiteConnection object through which to obtain data.
''' </summary>
''' <param name="mscConnection">A SQLiteConnection object.</param>
''' <remarks>This version of the constructor allows the developer to provide their own
''' SQLiteConnection object, allowing further manipulation of the connection prior to use
''' (you may, for example, wish to extend the ConnectionTimeout property beyond the default
''' value). Note that if you opt to provide your own SQLiteConnection object, you MUST manage
''' instantiation and disposal through your own code.</remarks>
''' <exception cref="NullExternalConnectionException">This exception
''' is thrown if the supplied connection evaulates to Nothing.</exception>
''' <exception cref="UnhandledException">This exception is thrown
''' if the constructor fails for any other reason.</exception>
Protected Sub New(ByRef mscConnection As SQLiteConnection)
Try
If mscConnection Is Nothing Then
Throw New NullExternalConnectionException
Else
Connection = mscConnection
End If
Catch ex As NullExternalConnectionException
Throw ex
Catch ex As Exception
Throw New UnhandledException(ex)
End Try
End Sub
#End Region
#Region " Methods "
''' <summary>
''' Instantiates the Internal connection.
''' </summary>
''' <exception cref="UnableToOpenConnectionException">This exception is thrown
''' if this method fails for any reason.</exception>
Protected Sub OpenConnection()
Try
' connect
Connection = New SQLiteConnection(ConnectionString)
Connection.Open()
' check connection
If Connection Is Nothing Then
Throw New UnableToOpenConnectionException
End If
Catch ex As UnableToOpenConnectionException
Throw ex
Catch ex As Exception
Throw New UnableToOpenConnectionException(ex)
End Try
End Sub
#End Region
End Class
''' <summary>
''' This Helper Class assists in populating a DataSet.
''' </summary>
Public Class DataSetHelper
Inherits HelperBase
#Region " Constructors "
''' <summary>
''' Sets the connection string when the Class is instantiated.
''' </summary>
''' <param name="strConnectionString">A connection string.</param>
''' <remarks></remarks>
Public Sub New(ByVal strConnectionString As String)
MyBase.New(strConnectionString)
End Sub
''' <summary>
''' Provides a SQLiteConnection object through which to obtain data.
''' </summary>
''' <param name="mscConnection">A SQLiteConnection object.</param>
''' <remarks>This version of the constructor allows the developer to provide their own
''' SQLiteConnection object, allowing further manipulation of the connection prior to use
''' (you may, for example, wish to extend the ConnectionTimeout property beyond the default
''' value). Note that if you opt to provide your own SQLiteConnection object, you MUST manage
''' instantiation and disposal through your own code.</remarks>
Public Sub New(ByRef mscConnection As System.Data.SQLite.SQLiteConnection)
MyBase.New(mscConnection)
End Sub
#End Region
#Region " Methods "
''' <summary>
''' Executes a SQL Statement, returning the result as a DataSet.
''' </summary>
''' <param name="strCommandText">A SQL Statement.</param>
''' <param name="mspParams">An array of SQL Statement Parameters.</param>
''' <param name="strTableName">The name of the source table for table mapping.</param>
''' <returns>A System.Data.DataSet object.</returns>
''' <remarks></remarks>
''' <exception cref="BadCommandException">This exception is thrown if the
''' sql command cannot be executed for any reason.</exception>
''' <exception cref="NullDataSetException">This exception is thrown
''' if the DataSet that results from the command evaluates to Nothing.</exception>
Public Function ExecuteDataSet(ByVal strCommandText As String, ByVal strTableName As String, ByVal ParamArray mspParams As SQLiteParameter()) As DataSet
Dim mscCommand As SQLiteCommand
Dim msdaAdapter As SQLiteDataAdapter
Dim dsDataSet As DataSet
Dim mspParam As SQLiteParameter
mscCommand = New SQLiteCommand
msdaAdapter = New SQLiteDataAdapter
dsDataSet = New DataSet
Try
' set up the command
OpenConnection()
mscCommand = New SQLiteCommand(strCommandText, Connection)
mscCommand.CommandType = CommandType.Text
' capture the params
If Not mspParams Is Nothing Then
For Each mspParam In mspParams
mscCommand.Parameters.Add(mspParam)
Next
End If
' execute
msdaAdapter.SelectCommand = mscCommand
msdaAdapter.Fill(dsDataSet, strTableName)
' check the command executed ok
If dsDataSet Is Nothing Then
Throw New NullDataSetException()
End If
Return dsDataSet
Catch ex As NullDataSetException
Throw ex
Catch ex As Exception
Throw New BadCommandException(ex)
Finally
mspParam = Nothing
msdaAdapter.Dispose()
msdaAdapter = Nothing
mscCommand.Dispose()
mscCommand = Nothing
Connection.Close()
End Try
End Function
#End Region
End Class
''' <summary>
''' Assists in execution of commands that do not return a recordset.
''' </summary>
Public Class NonQueryHelper
Inherits HelperBase
#Region " Constructors "
''' <summary>
''' Sets the connection string when the Class is instantiated.
''' </summary>
''' <param name="strConnectionString">A connection string.</param>
''' <remarks></remarks>
Public Sub New(ByVal strConnectionString As String)
MyBase.New(strConnectionString)
End Sub
''' <summary>
''' Provides a SQLiteConnection object through which to obtain data.
''' </summary>
''' <param name="mscConnection">A SQLiteConnection object.</param>
''' <remarks>This version of the constructor allows the developer to provide their own
''' SQLiteConnection object, allowing further manipulation of the connection prior to use
''' (you may, for example, wish to extend the ConnectionTimeout property beyond the default
''' value). Note that if you opt to provide your own SQLiteConnection object, you MUST manage
''' instantiation and disposal through your own code.</remarks>
Public Sub New(ByRef mscConnection As SQLiteConnection)
MyBase.New(mscConnection)
End Sub
#End Region
#Region " Methods "
''' <summary>
''' Executes a SQL Statement.
''' </summary>
''' <param name="strCommandText">A SQL Statement.</param>
''' <param name="mspParams">An array of SQL Statement Parameters.</param>
''' <returns>A 32-bit Integer; typically, the number of rows affected by the command.</returns>
''' <remarks></remarks>
''' <exception cref="BadCommandException">This exception is thrown if the
''' sql command cannot be executed for any reason.</exception>
Public Function ExecuteNonQuery(ByVal strCommandText As String, ByVal ParamArray mspParams As SQLiteParameter()) As Int32
Dim mscCommand As SQLiteCommand
Dim mspParam As SQLiteParameter
mscCommand = New SQLiteCommand
Try
' set up the command
OpenConnection()
mscCommand = New SQLiteCommand(strCommandText, Connection)
mscCommand.CommandType = CommandType.Text
' capture the params
If Not mspParams Is Nothing Then
For Each mspParam In mspParams
mscCommand.Parameters.Add(mspParam)
Next
End If
' execute
Return mscCommand.ExecuteNonQuery()
Catch ex As Exception
Throw New BadCommandException(ex)
Finally
mscCommand.Dispose()
mscCommand = Nothing
mspParam = Nothing
Connection.Close()
End Try
End Function
#End Region
End Class
''' <summary>
''' Assists in execution of commands that return a SQLiteDataReader object.
''' </summary>
Public Class ReaderHelper
Inherits HelperBase
#Region " Constructors "
''' <summary>
''' Sets the connection string when the Class is instantiated.
''' </summary>
''' <param name="strConnectionString">A connection string.</param>
''' <remarks></remarks>
Public Sub New(ByVal strConnectionString As String)
MyBase.New(strConnectionString)
End Sub
''' <summary>
''' Provides a SQLiteConnection object through which to obtain data.
''' </summary>
''' <param name="mscConnection">A SQLiteConnection object.</param>
''' <remarks>This version of the constructor allows the developer to provide their own
''' SQLiteConnection object, allowing further manipulation of the connection prior to use
''' (you may, for example, wish to extend the ConnectionTimeout property beyond the default
''' value). Note that if you opt to provide your own SQLiteConnection object, you MUST manage
''' instantiation and disposal through your own code.</remarks>
Public Sub New(ByRef mscConnection As SQLiteConnection)
MyBase.New(mscConnection)
End Sub
#End Region
#Region " Methods "
''' <summary>
''' Executes a SQL Statement, returning the result as a SQLiteDataReader.
''' </summary>
''' <param name="strCommandText">A SQL Statement.</param>
''' <param name="mspParams">An array of SQL Statement Parameters.</param>
''' <param name="cbBehaviour">The behavour of the command.</param>
''' <returns>A SQLiteDataReader object.</returns>
''' <remarks>You MUST close the helper's connection in your own code after using this method.</remarks>
''' <exception cref="BadCommandException">This exception is thrown if the
''' sql command cannot be executed for any reason.</exception>
''' <exception cref="NullDataReaderException">This exception is thrown
''' if the DataReader that results from the command evaluates to Nothing.</exception>
Public Function ExecuteReader(ByVal strCommandText As String, ByVal cbBehaviour As CommandBehavior, ByVal ParamArray mspParams As SQLiteParameter()) As SQLiteDataReader
Dim mscCommand As SQLiteCommand
Dim mspParam As SQLiteParameter
Dim msdrReader As SQLiteDataReader
mscCommand = New SQLiteCommand
Try
' set up the command
OpenConnection()
mscCommand = New SQLiteCommand(strCommandText, Connection)
mscCommand.CommandType = CommandType.Text
' capture the params
If Not mspParams Is Nothing Then
For Each mspParam In mspParams
mscCommand.Parameters.Add(mspParam)
Next
End If
' execute
msdrReader = mscCommand.ExecuteReader(cbBehaviour)
' check the command worked
If msdrReader Is Nothing Then
Throw New NullDataReaderException()
End If
Return msdrReader
Catch ex As NullDataReaderException
Throw ex
Catch ex As Exception
Throw New BadCommandException(ex)
Finally
mscCommand.Dispose()
mscCommand = Nothing
mspParam = Nothing
End Try
End Function
#End Region
End Class
''' <summary>
''' Assists in execution of commands that return an Object.
''' </summary>
Public Class ScalarHelper
Inherits HelperBase
#Region " Constructors "
''' <summary>
''' Sets the connection string when the Class is instantiated.
''' </summary>
''' <param name="strConnectionString">A connection string.</param>
''' <remarks></remarks>
Public Sub New(ByVal strConnectionString As String)
MyBase.New(strConnectionString)
End Sub
''' <summary>
''' Provides a SQLiteConnection object through which to obtain data.
''' </summary>
''' <param name="mscConnection">A SQLiteConnection object.</param>
''' <remarks>This version of the constructor allows the developer to provide their own
''' SQLiteConnection object, allowing further manipulation of the connection prior to use
''' (you may, for example, wish to extend the ConnectionTimeout property beyond the default
''' value). Note that if you opt to provide your own SQLiteConnection object, you MUST manage
''' instantiation and disposal through your own code.</remarks>
Public Sub New(ByRef mscConnection As SQLiteConnection)
MyBase.New(mscConnection)
End Sub
#End Region
#Region " Methods "
''' <summary>
''' Executes a SQL Statement, returning the result as an Object.
''' </summary>
''' <param name="strCommandText">A SQL Statement.</param>
''' <param name="mspParams">An array of SQL Statement Parameters.</param>
''' <returns>An Object.</returns>
''' <remarks></remarks>
''' <exception cref="BadCommandException">This exception is thrown if the
''' sql command cannot be executed for any reason.</exception>
Public Function ExecuteScalar(ByVal strCommandText As String, ByVal ParamArray mspParams As SQLiteParameter()) As Object
Dim mscCommand As SQLiteCommand
Dim mspParam As SQLiteParameter
mscCommand = New SQLiteCommand
Try
' set up the command
OpenConnection()
mscCommand = New SQLiteCommand(strCommandText, Connection)
mscCommand.CommandType = CommandType.Text
' capture the params
If Not mspParams Is Nothing Then
For Each mspParam In mspParams
mscCommand.Parameters.Add(mspParam)
Next
End If
' execute
Return mscCommand.ExecuteScalar
Catch ex As Exception
Throw New BadCommandException(ex)
Finally
mscCommand.Dispose()
mscCommand = Nothing
mspParam = Nothing
Connection.Close()
End Try
End Function
#End Region
End Class
''' <summary>
''' Provides Sql data conversion functions
''' </summary>
Public Class ConversionHelper
#Region "Methods"
''' <summary>
''' Converts a DateTime into a string suitable for use in Sql queries
''' </summary>
''' <param name="dtDateTime">The DateTime to convert.</param>
''' <returns>A String object.</returns>
''' <remarks>Returns the supplied date in a single-quote enclosed string, formatted yyyy/mm/dd hh:mm:ss</remarks>
''' <exception cref="ConversionFailureException">This exception is thrown if
''' the conversion fails for any reason.</exception>
Public Shared Function ToSqlDateTime(ByVal dtDateTime As DateTime) As String
Try
Return "'" & Format(dtDateTime.Year, "0000") & _
"/" & Format(dtDateTime.Month, "00") & _
"/" & Format(dtDateTime.Day, "00") & _
" " & Format(dtDateTime.Hour, "00") & _
":" & Format(dtDateTime.Minute, "00") & _
":" & Format(dtDateTime.Second, "00") & "'"
Catch ex As Exception
Throw New ConversionFailureException(ex)
End Try
End Function
''' <summary>
''' Converts a string into a string suitable for use in Sql queries
''' </summary>
''' <param name="strString">The String to convert.</param>
''' <returns>A String object.</returns>
''' <remarks>Returns the supplied string in a single-quote enclosed string.
''' Any single-quote characters in the original string are escaped.</remarks>
''' <exception cref="ConversionFailureException">This exception is thrown if
''' the conversion fails for any reason.</exception>
Public Shared Function ToSqlString(ByVal strString As String) As String
Try
If Not strString = String.Empty Then
Return "'" & strString.Replace("'", "\'") & "'"
Else
Return String.Empty
End If
Catch ex As Exception
Throw New ConversionFailureException(ex)
End Try
End Function
''' <summary>
''' Converts a Guid into a string suitable for use in Sql queries
''' </summary>
''' <param name="guidGuid">The Guid to convert.</param>
''' <returns>A String object.</returns>
''' <remarks>Returns a representation of the supplied Guid in a single-quote
''' enclosed string.</remarks>
''' <exception cref="ConversionFailureException">This exception is thrown if
''' the conversion fails for any reason.</exception>
Public Shared Function ToSqlGuid(ByVal guidGuid As Guid) As String
Try
If Not guidGuid.CompareTo(Guid.Empty) = 0 Then
Return String.Empty
Else
Return guidGuid.ToString.Replace("{", String.Empty).Replace("}", String.Empty)
End If
Catch ex As Exception
Throw New ConversionFailureException(ex)
End Try
End Function
''' <summary>
''' Converts a Sql VarChar into a system Guid.
''' </summary>
''' <param name="objValue">The Sql VarChar to convert.</param>
''' <returns>A System.Guid object.</returns>
''' <remarks>Returns Guid.Empty if the object is null or evaluates to empty string.</remarks>
''' <exception cref="ConversionFailureException">This exception is thrown if
''' the conversion fails for any reason.</exception>
Public Shared Function FromSqlGuid(ByVal objValue As Object) As Guid
Try
If objValue Is DBNull.Value Then
Return Guid.Empty
ElseIf objValue.ToString = String.Empty Then
Return Guid.Empty
Else
Return New Guid(objValue.ToString)
End If
Catch ex As Exception
Throw New ConversionFailureException(ex)
End Try
End Function
#End Region
End Class
''' <summary>
''' Assists smooth creation of SQLite Parameters.
''' </summary>
Public Class ParameterHelper
#Region " Methods "
''' <summary>
''' Compresses creation of a Sql Parameter into a single line of code
''' </summary>
''' <param name="strName">The Parameter name.</param>
''' <param name="objValue">The Parameter value.</param>
''' <param name="msdtType">The Parameter data type.</param>
''' <returns>A SQLiteParameter object.</returns>
''' <exception cref="BadParameterException">This exception is thrown if
''' the parameter creation process fails for any reason.</exception>
Public Shared Function CreateParameter(ByVal strName As String, ByVal objValue As Object, ByVal msdtType As DbType) As SQLiteParameter
Dim mspParam As SQLiteParameter
Try
mspParam = New SQLiteParameter(strName, objValue)
mspParam.DbType = msdtType
Return mspParam
Catch ex As Exception
Throw New BadParameterException(ex)
End Try
End Function
#End Region
End Class
End Namespace
Namespace DMFL.Data.SQLite.DAL.Exceptions
''' <summary>
''' This exception class is raised if the sql command fails.
''' </summary>
Public Class BadCommandException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the BadCommandException class.
''' </summary>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal eInnerException As Exception)
MyBase.New("The command failed - see InnerException for more details.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if a parameter creation method fails.
''' </summary>
Public Class BadParameterException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the BadParameterException class.
''' </summary>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal eInnerException As Exception)
MyBase.New("The parameter creation failed - see InnerException for more details.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if a data conversion method fails.
''' </summary>
Public Class ConversionFailureException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the ConversionFailureException class.
''' </summary>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal eInnerException As Exception)
MyBase.New("The data conversion failed - see InnerException for more details.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if a command returns a null datareader.
''' </summary>
Public Class NullDataReaderException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the NullDataReaderException class.
''' </summary>
Public Sub New()
MyBase.New("Command execution failed to return a non-Null SQLiteDataReader.")
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if a command returns a null dataset.
''' </summary>
Public Class NullDataSetException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the NullDataSetException class.
''' </summary>
Public Sub New()
MyBase.New("Command execution failed to return a non-Null DataSet")
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if an provided external data connection
''' is Nothing.
''' </summary>
Public Class NullExternalConnectionException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the NullExternalConnectionException class.
''' </summary>
Public Sub New()
MyBase.New("The supplied external connection is Nothing.")
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if the sql command fails.
''' </summary>
Public Class UnableToDeleteException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the UnableToDeleteException class.
''' </summary>
''' <param name="strTableName">The name of the table for which
''' the delete failed.</param>
Public Sub New(ByVal strTableName As String)
Me.New(strTableName, Nothing)
End Sub
''' <summary>
''' Constructor for the UnableToDeleteException class.
''' </summary>
''' <param name="strTableName">The name of the table for which
''' the delete failed.</param>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal strTableName As String, ByVal eInnerException As Exception)
MyBase.New("An attempt to Delete a row from table '" & strTableName & "' failed.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if the sql command fails.
''' </summary>
Public Class UnableToInsertException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the UnableToInsertException class.
''' </summary>
''' <param name="strTableName">The name of the table into which
''' the insert failed.</param>
Public Sub New(ByVal strTableName As String)
Me.New(strTableName, Nothing)
End Sub
''' <summary>
''' Constructor for the UnableToInsertException class.
''' </summary>
''' <param name="strTableName">The name of the table into which
''' the insert failed.</param>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal strTableName As String, ByVal eInnerException As Exception)
MyBase.New("An attempt to Insert a row into table '" & strTableName & "' failed.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if a connection to the database cannot
''' be opened.
''' </summary>
Public Class UnableToOpenConnectionException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the UnableToOpenConnectionException class.
''' </summary>
Public Sub New()
Me.New(Nothing)
End Sub
''' <summary>
''' Constructor for the UnableToOpenConnectionException class.
''' </summary>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal eInnerException As Exception)
MyBase.New("Unable to open the Sql connection.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if the sql command fails.
''' </summary>
Public Class UnableToUpdateException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the UnableToUpdateException class.
''' </summary>
''' <param name="strTableName">The name of the table for which
''' the update failed.</param>
Public Sub New(ByVal strTableName As String)
Me.New(strTableName, Nothing)
End Sub
''' <summary>
''' Constructor for the UnableToUpdateException class.
''' </summary>
''' <param name="strTableName">The name of the table for which
''' the update failed.</param>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal strTableName As String, ByVal eInnerException As Exception)
MyBase.New("An attempt to Update a row in table '" & strTableName & "' failed.", eInnerException)
End Sub
#End Region
End Class
''' <summary>
''' This exception class is raised if an otherwise unhandled exception occurs.
''' </summary>
Public Class UnhandledException
Inherits Exception
#Region " Constructors "
''' <summary>
''' Constructor for the UnhandledException class.
''' </summary>
''' <param name="eInnerException">More specific information
''' about the exception.</param>
Public Sub New(ByVal eInnerException As Exception)
MyBase.New("An unhandled exception occurred - see InnerException for more information.", eInnerException)
End Sub
#End Region
End Class
End Namespace
Please note - code is supplied untested and without warranty - if it's badly bust, let me know and I'll fix it! Similarly, if you fix something in it, please let me know. Obviously, if you're dumb enough to throw this straight into a business-critical app, your liability is entirely your own.
Example usage:
Dim rhHelper As New ReaderHelper("data source=C:\Documents and Settings\Me\My Documents\TestDb.s3db;")
Dim sdrReader As SQLiteDataReader = Nothing
Try
sdrReader = rhHelper.ExecuteReader("SELECT Id, Text FROM TestTable Where Id=@Id", _
CommandBehavior.Default, _
CreateParameter("@Id", 1, DbType.Int32))
While sdrReader.Read
Dim intId As Int32 = Convert.ToInt32(sdrReader("Id"))
Dim strText As String = sdrReader("Text").ToString
Console.WriteLine(intId.ToString + ": " + strText)
End While
Catch ex As Exception
Throw ex
Finally
If Not sdrReader Is Nothing Then
sdrReader.Close()
sdrReader = Nothing
End If
rhHelper.Connection.Close()
rhHelper = Nothing
End Try
