|
Prev: How check to see if string converts to Guid ok?
Next: "went" keyword in Visual Basic Language Specification 9.0
From: John on 3 Jul 2008 21:02 Hi I am using below in my dataadapter SELECT statement; SELECT <field list> FROM Clients WHERE (Status = ?) ORDER BY ID What if I need all clients regardless of status, is there a way to modify the above statement to include this situation or is a second query needed for that? Thanks Regards
From: Cor Ligthert[MVP] on 3 Jul 2008 23:00 John, I never tried this with an inline Sql procedure , but you can try Where(status is null or status = ?) And please let us know if this works. I assume you are using OleDB because you use the ? In a SQL stored procedure you simple declare a parameter as @Status bool = null and then Where (@Status is null or Status = @Status) Cor "John" <info(a)nospam.infovis.co.uk> schreef in bericht news:%2372UxGX3IHA.5060(a)TK2MSFTNGP02.phx.gbl... > Hi > > I am using below in my dataadapter SELECT statement; > > SELECT <field list> > FROM Clients > WHERE (Status = ?) > ORDER BY ID > > What if I need all clients regardless of status, is there a way to modify > the above statement to include this situation or is a second query needed > for that? > > Thanks > > Regards >
From: John on 4 Jul 2008 18:34 Hi Cor Doesn't work. Thanks Regards "Cor Ligthert[MVP]" <notmyfirstname(a)planet.nl> wrote in message news:62A90734-00F6-4BB1-B02F-409D5C980628(a)microsoft.com... > John, > > I never tried this with an inline Sql procedure , but you can try > > Where(status is null or status = ?) > > And please let us know if this works. I assume you are using OleDB because > you use the ? > > In a SQL stored procedure you simple declare a parameter as > > @Status bool = null > > and then > > Where (@Status is null or Status = @Status) > > Cor > > "John" <info(a)nospam.infovis.co.uk> schreef in bericht > news:%2372UxGX3IHA.5060(a)TK2MSFTNGP02.phx.gbl... >> Hi >> >> I am using below in my dataadapter SELECT statement; >> >> SELECT <field list> >> FROM Clients >> WHERE (Status = ?) >> ORDER BY ID >> >> What if I need all clients regardless of status, is there a way to modify >> the above statement to include this situation or is a second query needed >> for that? >> >> Thanks >> >> Regards >> >
From: Jack Jackson on 5 Jul 2008 01:42 On Fri, 4 Jul 2008 02:02:57 +0100, "John" <info(a)nospam.infovis.co.uk> wrote: >Hi > >I am using below in my dataadapter SELECT statement; > >SELECT <field list> >FROM Clients >WHERE (Status = ?) >ORDER BY ID > >What if I need all clients regardless of status, is there a way to modify >the above statement to include this situation or is a second query needed >for that? > >Thanks > >Regards > You could try: SELECT ... FROM ... WHERE ? IS NULL OR Status = ? ORDER BY ... and pass in NULL for the parameter to get all records. I assume you are using OLEDB, and I don't know it if allows a parameter to be tested like that.
From: John on 5 Jul 2008 13:50
Does not work as both ? become two separate parameters. Thanks Regards "Jack Jackson" <jjackson(a)cinnovations.net> wrote in message news:382u64599ju6vavsugq5id9s932oncdtn2(a)4ax.com... > On Fri, 4 Jul 2008 02:02:57 +0100, "John" <info(a)nospam.infovis.co.uk> > wrote: > >>Hi >> >>I am using below in my dataadapter SELECT statement; >> >>SELECT <field list> >>FROM Clients >>WHERE (Status = ?) >>ORDER BY ID >> >>What if I need all clients regardless of status, is there a way to modify >>the above statement to include this situation or is a second query needed >>for that? >> >>Thanks >> >>Regards >> > > You could try: > SELECT ... FROM ... WHERE ? IS NULL OR Status = ? ORDER BY ... > > and pass in NULL for the parameter to get all records. I assume you > are using OLEDB, and I don't know it if allows a parameter to be > tested like that. |