''' <summary> ''' Get's the id associated with the code ''' </summary> ''' <param name="code"></param> ''' <returns> ''' an integer if the code being request was found. ''' 0 if the code was not found ''' </returns> Public Shared Function GetID(code As String) As Integer Using connection As SqlConnection _ = New SqlConnection(ConnectSP.GetConnectionString())
Dim sqlStatement As String _ = "select ID " _ & "from Admin_Analysis_Type " _ & "where code=@code"
Using command As SqlCommand = New SqlCommand(sqlStatement, connection) command.Parameters.Add(New SqlParameter("@code", SqlDbType.VarChar, 50)).Value = code
Using datareader As SqlDataReader = command.ExecuteReader() If datareader.Read() Then Return datareader.GetValue(0) End If End Using End Using End Using Return 0 End Function