VB.Net - SQL

Goal of this code was to call a stored procedure with a parameter. Existing code had a memory leak this was the fix.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Public Shared Function getContractStatus(ByVal ConnectString As String, _
ByRef errmsg As String) As DataSet
Dim oConnection As New SqlConnection
Dim oCommand As New SqlCommand
Dim oDataAdaptor As New SqlDataAdapter
Dim DS As New DataSet
errmsg = "OK"
Try
oConnection.ConnectionString = ConnectString
oConnection.Open()
oCommand.Connection = oConnection
oCommand.CommandType = CommandType.StoredProcedure
oCommand.CommandText = "CMS_SRCH_GETCONTSTATUS"
'oCommand.Parameters.Add(New SqlParameter("io_cursor", SqlDbType.VarChar)).Direction = ParameterDirection.Output
oDataAdaptor.SelectCommand = oCommand
oDataAdaptor.Fill(DS, "ValidationValues")
Catch ex As Exception
errmsg = "Module: DataLayer.Common_DL.GetContractStatus, Error: " + ex.Message
Finally
If oConnection.State = ConnectionState.Open Then
oConnection.Close()
End If
oCommand.Dispose()
End Try
Return DS
End Function