/ Published in: VB.NET
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.
Expand |
Embed | Plain Text
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
You need to login to post a comment.
