Bitmask operation returning zero rows

Posts   
 
    
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 26-Jun-2006 14:27:45   

Hi Otis,

Following on from http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6661

The saga continues... I now have a where statement for a bitmask check that looks fine, if i run it in Microsoft Query Analyzer I get the rows I expect returned but through the application (llb) I am getting zero rows returned.

I have included the where clause and the parameter info below for both the hardcoded 0x01 and the looped variable, notice the difference in types passed in, isthis significant?

If I cant get this working today, I may have to go to a stored procedure rage

Below is the 0x01 hardcoded SQL

WHERE ( [mallett_WMS01].[CustomerOption].[cop_checkoptions] & @LO8082 = @Cop_checkoptions1) Parameter: @Cop_checkoptions1 : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1. Parameter: @LO8082 : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1.

Below is the ulong values passed in from the loop:

WHERE ( [mallett_WMS01].[CustomerOption].[cop_checkoptions] & @LO6422 = @Cop_checkoptions1) Parameter: @Cop_checkoptions1 : AnsiString. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1. Parameter: @LO6422 : AnsiString. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1.

Cheers

Richard

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 26-Jun-2006 14:59:22   

WHere does that AnsiString come from? It seems the value is passed as a string instead of an int.

Could you paste the code you're using?

I'll close the other thread.

Frans Bouma | Lead developer LLBLGen Pro
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 26-Jun-2006 15:10:09   

Hi Otis

Thanks for the reply, sorry if this is getting a confusing thread, I hope I am not doing anything stupid. The following code is the one that produces the ansi string, you can substitue the bit variable for 0x01 to get the int32 result being passed as a parameter, however in both cases I get no rows returned. But in query analyzer I get the correct rows returned.

Again thanks for your reply, after last night's game I would be in no mood to come to work!rage

I think I closed the last thread off, let me know if there is anything else you may need.

Cheers

Rich

Filter Generation

IPredicateExpression filter = new PredicateExpression();

//option filter if (SearchCheckedOptionsOnly) { //The new filter to use for(int i=0; i < 32; i++) { ulong bit = (ulong)System.Math.Pow(2, i);

    if ((bit & CheckedOptions) > 0) {
        filter.Add(CustomerOptionFields.Cop_checkoptions.SetExpression(new Expression(CustomerOptionFields.Cop_checkoptions, ExOp.BitwiseAnd, bit)) == bit);
    }
}
return filter;

}

Call to populate the collection (Calls the above code)

StockCollection collection = new StockCollection();

if (search.SearchStockIdsOnly && search.StockIds.Count == 0) { ///return a list of null as we should only return stockids return collection; }

IPredicateExpression filter = search.GenerateFilter(); SortExpression sorter = search.GenerateSort();

collection.GetMulti(filter, search.PageSize, sorter, null, search.CurrentPage+1, search.PageSize);

rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 26-Jun-2006 19:14:17   

Hi Otis,

Just got back on this problem. Your code was correct and all now working. I had a database issue where my connection string was being changed to our live server, hence the rows being returned. Thanks for your time on this.

Regards

Richard