PC Review


Reply
Thread Tools Rate Thread

DataAdapter W/Parameters

 
 
=?Utf-8?B?SmltSGVhdmV5?=
Guest
Posts: n/a
 
      21st Nov 2007
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!!!


 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      21st Nov 2007
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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parameters for DataAdapter =?Utf-8?B?am9uZWZlcg==?= Microsoft Dot NET 2 16th Dec 2005 05:44 PM
Adding Parameters to WHERE clause in DataAdapter Mike D Microsoft C# .NET 3 17th Dec 2004 03:03 PM
DataGrid, DataAdapter, SP Parameters? James Microsoft ASP .NET 1 7th Oct 2004 12:21 PM
Re: DataAdapter Select with Parameters jack Microsoft VB .NET 1 2nd Jul 2004 06:08 PM
Parameters with DataAdapter commands Predrag Microsoft ADO .NET 1 17th Mar 2004 02:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:31 AM.