PC Review


Reply
Thread Tools Rate Thread

Parameters annd SQLDataAdapter

 
 
Denis Blondeau
Guest
Posts: n/a
 
      20th May 2004
Is it possible to use a wildcard as a parameter? For example, sometime I
want to use a paramater to get only a subset of rows in a table but sometime
I want to get all the rows.

I tried deleting the parameter itself (e.g. @CallID) but I will get an SQL
adapter as the parameter, even if deleted, is still in the Commandtext of
the SQLAdapter.

The only way I can get this to work is to also modify the commandtext (i.e.
removing any reference to that parameter in the SELECT command).

-> Denis



 
Reply With Quote
 
 
 
 
Damien Foggon
Guest
Posts: n/a
 
      20th May 2004
The way that I've done this in the past is to use null as the default
value for the parameter and not pass it if needed.

creates objects (Command, Connection, etc.)

if (Parameter required)
add it
end if

call ExecuteXXX

And then the SP would be (or whatever you need to do - just check for IS
NULL):

CREATE PROCEDURE dbo.stpTest
@id int = null
AS

IF (@id IS NULL) BEGIN

END ELSE BEGIN

END



Denis Blondeau wrote:
> Is it possible to use a wildcard as a parameter? For example, sometime I
> want to use a paramater to get only a subset of rows in a table but sometime
> I want to get all the rows.
>
> I tried deleting the parameter itself (e.g. @CallID) but I will get an SQL
> adapter as the parameter, even if deleted, is still in the Commandtext of
> the SQLAdapter.
>
> The only way I can get this to work is to also modify the commandtext (i.e.
> removing any reference to that parameter in the SELECT command).
>
> -> Denis
>
>
>

 
Reply With Quote
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      21st May 2004
Hi Denis,

Nope, it is not possible directly. There are workarounds though - you could
modify sql select command in the way that if gets null value of a parameter
it ignores it.
Or, you could build on the fly your sql select command and add those
parameters you need.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Denis Blondeau" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is it possible to use a wildcard as a parameter? For example, sometime I
> want to use a paramater to get only a subset of rows in a table but

sometime
> I want to get all the rows.
>
> I tried deleting the parameter itself (e.g. @CallID) but I will get an SQL
> adapter as the parameter, even if deleted, is still in the Commandtext of
> the SQLAdapter.
>
> The only way I can get this to work is to also modify the commandtext

(i.e.
> removing any reference to that parameter in the SELECT command).
>
> -> Denis
>
>
>



 
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
How can i make a help file with parameters as the menus parameters =?Utf-8?B?S2ltb24=?= Microsoft Access 0 21st Oct 2005 06:56 PM
Passing output parameters to SQL Server stored procedures through an SqlCommand object's Parameters collection Mark Rae Microsoft ADO .NET 8 26th Sep 2005 04:28 PM
XP annd USB ethernet adapter... Stephane M Windows XP Configuration 0 13th Sep 2005 10:49 PM
{includetext} annd gray text Pat Ryan Microsoft Word New Users 2 9th Nov 2003 01:20 PM
Why is 2098 the maximum number of parameters in SqlCommand.Parameters Paul Clark Microsoft ADO .NET 3 24th Aug 2003 07:43 AM


Features
 

Advertising
 

Newsgroups
 


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