Kasper Hansen
Kasper Hansen

Reputation: 6557

Problem with debugging (method never called)

I am trying to execute a stored procedure, but the following line is giving me trouble:

result = this.sqlDalExternal.ExecuteStoredProcedure(SqlCommonExecutionType.DataTableResult, sqlCommand) as DataTable;

The method ExecuteStoredProcedure is apparantly never called. When debugging, I can step from one line to the next (as expected). Then when I am on this line and wants to go into, it just jumps to catch(Exception e). result has the value null.

sqlCommand.CommandText is set to the Stored Procedure name. Why is the method this.sqlDalExternal.ExecuteStoredProcedure never called?

    private DataTable ExecuteStoredProcedure(string storedProcedureName, Collection<SqlParameter> parameters)
    {
        DataTable result = null;

        try 
        {
            SqlCommand sqlCommand = new SqlCommand(storedProcedureName);
            if (parameters != null)
                foreach (SqlParameter parameter in parameters)
                    sqlCommand.Parameters.Add(parameter);

            result = this.sqlDalExternal.ExecuteStoredProcedure(SqlCommonExecutionType.DataTableResult, sqlCommand) as DataTable;
        }
        catch(Exception e)
        {
            throw new ExternalSystemAdapterException(9102, e.ToString());
        }
        return result;
    }

Upvotes: 0

Views: 97

Answers (2)

AakashM
AakashM

Reputation: 63338

"NullReferenceException was caught". And below it says "Object reference not set to an instance of an object."

suggests that this.sqlDalExternal is null, which therefore explains why the method is never called (since there is no object to call it on).

Upvotes: 1

Arnaud F.
Arnaud F.

Reputation: 8452

Maybe because the signature doesn't match between the called method and the method you want debug? :)

You call :

ExecuteStoredProcedure(SqlCommonExecutionType, SqlCommand)

The method you debug :

ExecuteStoredProcedure(string, Collection)

...

Upvotes: 1

Related Questions