DataAdapter W/Parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I used VS2005 to Created a Dataset and TableAdapter and a number of queries
for my Oracle Table. I created a "BLL" class to handle my Business Logic
Layer. One of the "Select" query has selection criteria for a number of
fields. I added at GridView to my form and bound my grid to the table
adapter and by BLL and the method which has a number of selection criteria
and I bound each of the selection criteria to the appropriate text boxes on
my web form.

My problem is that the criteria is variable, sometimes the user will supply
2 values for selection criteria....and other times they may specify more or
less, but there will always be one value specified...except when the form is
first loaded. I thought I could use the "Selecting" event of the
ObjectDataSource and look at the web form and get rid of the Parameters which
were not needed. On the Page Load, this deletes all the paramters and the
query fails with an error saying no parameters were present. I modified the
code to not do any deletes on Page Load. This then cause the query to fail,
as one of the parameters would not accept nulls.

So how do I overcome these obstacles?

Thanks in advance for your assistance!!!
 
Jim

If you change your select SQL query with

@MySecondParameter int = null

And then in the where

Where
(@mySecondParameter is null or @mySecondParameter = TheField)

Then you are almost there.

Cor
 
Back
Top