Revision: 61109
Updated Code
at November 28, 2012 22:43 by nimblebits
Updated Code
Private conn As OleDbConnection = New OleDbConnection() 'Private conn As New OleDbConnection Public Function doScalar(ByVal connString As String, ByVal command As OleDb.OleDbCommand) As Int32 Dim value As Int32 = 0 Try conn.ConnectionString = connString command.Connection = conn conn.Open() value = command.ExecuteScalar() Catch ex As Exception MsgBox("An Error Was Encountered:" & ex.Message, MsgBoxStyle.Information, "Database Error") Return Nothing Finally conn.Close() command.Dispose() End Try Return value End Function
Revision: 61108
Updated Code
at November 28, 2012 21:51 by nimblebits
Updated Code
Private conn As OleDbConnection = New OleDbConnection() Public Function doScalar(ByVal connString As String, ByVal command As OleDb.OleDbCommand) As Int32 Dim value As Int32 = 0 Try conn.ConnectionString = connString command.Connection = conn conn.Open() value = command.ExecuteScalar() Catch ex As Exception MsgBox("An Error Was Encountered:" & ex.Message, MsgBoxStyle.Information, "Database Error") Return Nothing Finally conn.Close() command.Dispose() End Try Return value End Function
Revision: 61107
Updated Code
at November 28, 2012 21:22 by nimblebits
Updated Code
Private conn As OleDbConnection = Nothing Public Function doScalar(ByVal connString As String, ByVal command As OleDb.OleDbCommand) As Int32 Dim value As Int32 = 0 Try conn.ConnectionString = connString command.Connection = conn conn.Open() value = command.ExecuteScalar() Catch ex As Exception MsgBox("An Error Was Encountered:" & ex.Message, MsgBoxStyle.Information, "Database Error") Return Nothing Finally conn.Close() command.Dispose() End Try Return value End Function
Revision: 61106
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 28, 2012 21:19 by nimblebits
Initial Code
Private conn as OleDbConnection = Nothing Public Function doScalar(ByVal connString As String, ByVal command As OleDb.OleDbCommand) As Int32 Dim value As Int32 = 0 Try conn.ConnectionString = connString command.Connection = conn conn.Open() value = command.ExecuteScalar() Catch ex As Exception MsgBox("An Error Was Encountered:" & ex.Message, MsgBoxStyle.Information, "Database Error") 'ToDo Log Error Return Nothing Finally conn.Close() command.Dispose() End Try Return value End Function
Initial URL
Initial Description
This is a method that can be used to take a connection string and a valid oledb command and perform a scalar. This returns an Integer/Int32 value.
Initial Title
VB.NET Method Perform Scalar
Initial Tags
sql, function
Initial Language
VB.NET