dao.GetAsDataReader return nothing.

Posts   
 
    
nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 11-May-2010 11:03:35   

IRetrievalQuery query = new RetrievalQuery(commandToUse);
        IDataReader reader = null;
        try
        {
            reader = dao.GetAsDataReader(null, query, CommandBehavior.Default);
            while (reader.Read())
            {
                Response.Write(string.Format("Amount:{0},CategoryId:{1},Name:{2}", info.Amount, info.CategoryId, info.Name));
            }

            //reader.Close();
        }
        catch (Exception exc)
        {
            throw exc;
        }
        finally
        {
            if (reader != null)
                reader.Close();
        }

query as follow:


{
    Query: call Expenses(@actionTypeId,@isSchedule,@userId,@dateStart,@dateEnd)
    Parameter: actionTypeId : AnsiString. Length: 1. Precision: 0. Scale: 0. Direction: Input. Value: "1".
    Parameter: isSchedule : AnsiString. Length: 1. Precision: 0. Scale: 0. Direction: Input. Value: "0".
    Parameter: userId : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1.
    Parameter: dateStart : AnsiString. Length: 10. Precision: 0. Scale: 0. Direction: Input. Value: "2010-01-01".
    Parameter: dateEnd : AnsiString. Length: 10. Precision: 0. Scale: 0. Direction: Input. Value: "2010-05-11".
}

the DB is MySQL 5.0 the result should have 5 rows.

current problem is : dao.GetAsDataReader return nothing.

please advise. Thank you.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 11-May-2010 18:02:12   

How is the commandToUse object created/setup ?

nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 12-May-2010 01:51:42   

how should i create commandToUse? my way as follows: first:


IDbCommand commandToUse = DynamicQueryEngine.FactoryToUse.CreateCommand();
        commandToUse.CommandText = "call Expenses(@actionTypeId,@isSchedule,@userId,@dateStart,@dateEnd)";
        commandToUse.CommandType = CommandType.Text;
        
        IDataParameterCollection parameters = commandToUse.Parameters;

        DbParameter pActionTypeId = DynamicQueryEngine.FactoryToUse.CreateParameter();
        pActionTypeId.ParameterName = "actionTypeId";
        pActionTypeId.Value = "1";
        commandToUse.Parameters.Add(pActionTypeId);

        ...... 

second way is change "DynamicQueryEngine.FactoryToUse.CreateCommand();" to "new Devart.Data.MySql.MySqlCommand();" and change "DynamicQueryEngine.FactoryToUse.CreateParameter();" to "new Devart.Data.MySql.MySqlParameter();"

becuase my MySql provider is Devart.Data.MySql.

Thank you.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-May-2010 03:09:43   

In your first post I don't get what "info" is. And the obvious question is: What you are not using a call to stored procedure via LLBLGen (read Calling a stored procedure).

David Elizondo | LLBLGen Support Team
nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 12-May-2010 03:11:33   

LLBL 2.6 doesn't support call Sp in Mysql.

nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 12-May-2010 04:29:40   

the problem was solved by myself.

commandToUse.CommandText should be changed to

commandToUse.CommandText = "call Expenses(?,?,?,?,?)";