Please help - rewriting code from VB.NET to C#

Oct 29 2004 2:21 PM
Hello all, I have this method that I had originally written in VB and am now writing it in C# and am having a problem. Can someone please answer my question and show me what I'm doing wrong. Thanks In Advance... 1) In VB I had a function that was of type SQLDataReader (please look at code below) and I returned the data but when I try to do the same in C# I get an error that states "Not all code paths return a value." I added the VB & C# code below for you to look at and show me what I need to do to get it to work. ************VB Code************************* Public Function openDataReader(ByVal sProc As String) As SqlDataReader Try If gblnConn Then 'Set Command properties With mSQLCmd .Connection = mSQLConn .CommandType = CommandType.StoredProcedure .CommandText = sProc openDataReader = .ExecuteReader(CommandBehavior.CloseConnection) End With Return openDataReader End If Catch ex As Exception mstrError = ex.Message End Try End Function ----------------------------------------------------------------------------------------------- ****************C# Code****************************************** public OracleDataReader OpenDataReader(string sProc) { try { if (gblnConn) { mORACmd = mORAConn.CreateCommand(); mORACmd.CommandText = sProc; mORACmd.CommandType = CommandType.StoredProcedure; mORADReader = mORACmd.ExecuteReader(CommandBehavior.CloseConnection); return mORADReader; } } catch(Exception ex) { mstrError = ex.Message; } }

Answers (2)