DbFunctionCall

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 08-Nov-2013 14:10:19   

LLBLGEN 4.0 LLBLGEN Runtime framework MYSQL

I am trying to get current date by using DB function call


var dt = new DataTable();
                var fields = new ResultsetFields(1);
                fields[1].ExpressionToApply = new DbFunctionCall("CURRENT_TIMESTAMP", new object[] {});
                var dao = new TypedListDAO();
                dao.GetMultiAsDataTable(fields, null, null, null);

Error: Index was outside the bounds of the array.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 08-Nov-2013 18:57:06   

You create a resultsetfields with size 1, so you can't set a field at index 1 wink

fields[1].ExpressionToApply = new DbFunctionCall("CURRENT_TIMESTAMP", new object[] {});

C# arrays / indexers start at 0.

Frans Bouma | Lead developer LLBLGen Pro
hotmail
User
Posts: 47
Joined: 06-Feb-2013
# Posted on: 17-Mar-2015 06:02:31   

i am trying to get a db function call to check if an object exists, the function returns bit value.


            var dt = new DataTable();
            var rf = new ResultsetFields(1);
            rf[0].ExpressionToApply = new DbFunctionCall("dbo", "SfObjectExists", new object[] { "Person", "u" });
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchTypedList(rf, dt, null);
            }

When i run it i get rf[0] is null exception . Is the correct way to call the scalar value function? LLBL v4.2 latest, VS2013, SQL Server 2014.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-Mar-2015 14:06:53   

You're calling FetchTypedList to call a scalar, so no, it's not the right way to call a scalar wink Call GetScalar instead.

(and please don't reopen old threads of not related problems. You should know that by now, Hotmail wink )

Frans Bouma | Lead developer LLBLGen Pro