Tuesday, March 20, 2012

Passing a WHERE clause

I want to build a SQL WHERE (and possibly ORDER BY) clause
in a c# application and then pass them as parameters to a report that would
be used by a SQL Server stored procedure.
can anyone tell me how to do that?
Syntax for building it?
maybe a link to an example?
thanks
--
Lucas DargisYou have a very good sample available in samples. search for forms
authentication and open the custom security c# file and see the code you will
get good idea about how to write.
Amarnath
"akbikerboy" wrote:
> I want to build a SQL WHERE (and possibly ORDER BY) clause
> in a c# application and then pass them as parameters to a report that would
> be used by a SQL Server stored procedure.
> can anyone tell me how to do that?
> Syntax for building it?
> maybe a link to an example?
> thanks
> --
> Lucas Dargis|||could you be more specific?
Are you talking about MSDN or in VS?
I can't find what you are talking about
thanks
--
Lucas Dargis
"Amarnath" wrote:
> You have a very good sample available in samples. search for forms
> authentication and open the custom security c# file and see the code you will
> get good idea about how to write.
> Amarnath
> "akbikerboy" wrote:
> > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > in a c# application and then pass them as parameters to a report that would
> > be used by a SQL Server stored procedure.
> >
> > can anyone tell me how to do that?
> > Syntax for building it?
> > maybe a link to an example?
> >
> > thanks
> > --
> > Lucas Dargis|||sql server online help samples
Amarnath
"akbikerboy" wrote:
> could you be more specific?
> Are you talking about MSDN or in VS?
> I can't find what you are talking about
>
> thanks
> --
> Lucas Dargis
>
> "Amarnath" wrote:
> > You have a very good sample available in samples. search for forms
> > authentication and open the custom security c# file and see the code you will
> > get good idea about how to write.
> >
> > Amarnath
> >
> > "akbikerboy" wrote:
> >
> > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > in a c# application and then pass them as parameters to a report that would
> > > be used by a SQL Server stored procedure.
> > >
> > > can anyone tell me how to do that?
> > > Syntax for building it?
> > > maybe a link to an example?
> > >
> > > thanks
> > > --
> > > Lucas Dargis|||I looked all over and i can't find what your are talking about. do you have a
link to it?
--
Lucas Dargis
"Amarnath" wrote:
> sql server online help samples
> Amarnath
> "akbikerboy" wrote:
> > could you be more specific?
> > Are you talking about MSDN or in VS?
> > I can't find what you are talking about
> >
> >
> > thanks
> > --
> > Lucas Dargis
> >
> >
> > "Amarnath" wrote:
> >
> > > You have a very good sample available in samples. search for forms
> > > authentication and open the custom security c# file and see the code you will
> > > get good idea about how to write.
> > >
> > > Amarnath
> > >
> > > "akbikerboy" wrote:
> > >
> > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > in a c# application and then pass them as parameters to a report that would
> > > > be used by a SQL Server stored procedure.
> > > >
> > > > can anyone tell me how to do that?
> > > > Syntax for building it?
> > > > maybe a link to an example?
> > > >
> > > > thanks
> > > > --
> > > > Lucas Dargis|||Just go to search in online help and search for forms authentication and if
you have installed the samples, go to the samples folder and see the forms
authentication example code.
Amarnath
"akbikerboy" wrote:
> I looked all over and i can't find what your are talking about. do you have a
> link to it?
> --
> Lucas Dargis
>
> "Amarnath" wrote:
> > sql server online help samples
> >
> > Amarnath
> >
> > "akbikerboy" wrote:
> >
> > > could you be more specific?
> > > Are you talking about MSDN or in VS?
> > > I can't find what you are talking about
> > >
> > >
> > > thanks
> > > --
> > > Lucas Dargis
> > >
> > >
> > > "Amarnath" wrote:
> > >
> > > > You have a very good sample available in samples. search for forms
> > > > authentication and open the custom security c# file and see the code you will
> > > > get good idea about how to write.
> > > >
> > > > Amarnath
> > > >
> > > > "akbikerboy" wrote:
> > > >
> > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > in a c# application and then pass them as parameters to a report that would
> > > > > be used by a SQL Server stored procedure.
> > > > >
> > > > > can anyone tell me how to do that?
> > > > > Syntax for building it?
> > > > > maybe a link to an example?
> > > > >
> > > > > thanks
> > > > > --
> > > > > Lucas Dargis|||there are a million articles about forms authentication. and i don't see what
that has to do with passing a where clause from an application to RS...
thanks for trying though.
--
Lucas Dargis
"Amarnath" wrote:
> Just go to search in online help and search for forms authentication and if
> you have installed the samples, go to the samples folder and see the forms
> authentication example code.
> Amarnath
> "akbikerboy" wrote:
> > I looked all over and i can't find what your are talking about. do you have a
> > link to it?
> > --
> > Lucas Dargis
> >
> >
> > "Amarnath" wrote:
> >
> > > sql server online help samples
> > >
> > > Amarnath
> > >
> > > "akbikerboy" wrote:
> > >
> > > > could you be more specific?
> > > > Are you talking about MSDN or in VS?
> > > > I can't find what you are talking about
> > > >
> > > >
> > > > thanks
> > > > --
> > > > Lucas Dargis
> > > >
> > > >
> > > > "Amarnath" wrote:
> > > >
> > > > > You have a very good sample available in samples. search for forms
> > > > > authentication and open the custom security c# file and see the code you will
> > > > > get good idea about how to write.
> > > > >
> > > > > Amarnath
> > > > >
> > > > > "akbikerboy" wrote:
> > > > >
> > > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > > in a c# application and then pass them as parameters to a report that would
> > > > > > be used by a SQL Server stored procedure.
> > > > > >
> > > > > > can anyone tell me how to do that?
> > > > > > Syntax for building it?
> > > > > > maybe a link to an example?
> > > > > >
> > > > > > thanks
> > > > > > --
> > > > > > Lucas Dargis|||dude, I didn't ask you to type it on google to get million option. By the way
I was mentioning that if you have sample installed, you can have a look at
the sample code, I repeat the code, so that you will get some idea for
writing code in c# or VB.net.
Amarnath
"akbikerboy" wrote:
> there are a million articles about forms authentication. and i don't see what
> that has to do with passing a where clause from an application to RS...
> thanks for trying though.
> --
> Lucas Dargis
>
> "Amarnath" wrote:
> > Just go to search in online help and search for forms authentication and if
> > you have installed the samples, go to the samples folder and see the forms
> > authentication example code.
> >
> > Amarnath
> >
> > "akbikerboy" wrote:
> >
> > > I looked all over and i can't find what your are talking about. do you have a
> > > link to it?
> > > --
> > > Lucas Dargis
> > >
> > >
> > > "Amarnath" wrote:
> > >
> > > > sql server online help samples
> > > >
> > > > Amarnath
> > > >
> > > > "akbikerboy" wrote:
> > > >
> > > > > could you be more specific?
> > > > > Are you talking about MSDN or in VS?
> > > > > I can't find what you are talking about
> > > > >
> > > > >
> > > > > thanks
> > > > > --
> > > > > Lucas Dargis
> > > > >
> > > > >
> > > > > "Amarnath" wrote:
> > > > >
> > > > > > You have a very good sample available in samples. search for forms
> > > > > > authentication and open the custom security c# file and see the code you will
> > > > > > get good idea about how to write.
> > > > > >
> > > > > > Amarnath
> > > > > >
> > > > > > "akbikerboy" wrote:
> > > > > >
> > > > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > > > in a c# application and then pass them as parameters to a report that would
> > > > > > > be used by a SQL Server stored procedure.
> > > > > > >
> > > > > > > can anyone tell me how to do that?
> > > > > > > Syntax for building it?
> > > > > > > maybe a link to an example?
> > > > > > >
> > > > > > > thanks
> > > > > > > --
> > > > > > > Lucas Dargis|||Ok, to guide you precisly,
If you have samples installed in your m/c, go to
C:\Program Files\Microsoft SQL Server\90\Samples\Reporting
Services\Extension Samples\FormsAuthentication Sample\cs (change folder name
accordingly)
you can see a custom security solution file, click on that and open. search
for
"AuthenticationExtension.cs" file and click on view code and search for
"VerifyUser"
In that code you can see how it is defined for stored procedure using
commandtype
and parameter.add is used. instead of "@.username" build your where clause by
defining a variable and start adding all the conditions and pass it on using
parameter.add.
I think this should give some idea about how to write it.
Please let me know if you have any problems
Amarnath
"akbikerboy" wrote:
> there are a million articles about forms authentication. and i don't see what
> that has to do with passing a where clause from an application to RS...
> thanks for trying though.
> --
> Lucas Dargis
>
> "Amarnath" wrote:
> > Just go to search in online help and search for forms authentication and if
> > you have installed the samples, go to the samples folder and see the forms
> > authentication example code.
> >
> > Amarnath
> >
> > "akbikerboy" wrote:
> >
> > > I looked all over and i can't find what your are talking about. do you have a
> > > link to it?
> > > --
> > > Lucas Dargis
> > >
> > >
> > > "Amarnath" wrote:
> > >
> > > > sql server online help samples
> > > >
> > > > Amarnath
> > > >
> > > > "akbikerboy" wrote:
> > > >
> > > > > could you be more specific?
> > > > > Are you talking about MSDN or in VS?
> > > > > I can't find what you are talking about
> > > > >
> > > > >
> > > > > thanks
> > > > > --
> > > > > Lucas Dargis
> > > > >
> > > > >
> > > > > "Amarnath" wrote:
> > > > >
> > > > > > You have a very good sample available in samples. search for forms
> > > > > > authentication and open the custom security c# file and see the code you will
> > > > > > get good idea about how to write.
> > > > > >
> > > > > > Amarnath
> > > > > >
> > > > > > "akbikerboy" wrote:
> > > > > >
> > > > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > > > in a c# application and then pass them as parameters to a report that would
> > > > > > > be used by a SQL Server stored procedure.
> > > > > > >
> > > > > > > can anyone tell me how to do that?
> > > > > > > Syntax for building it?
> > > > > > > maybe a link to an example?
> > > > > > >
> > > > > > > thanks
> > > > > > > --
> > > > > > > Lucas Dargis|||Well thanks for pointing that out precisely.
I guess I should have been more specific. I know how to create and pass a
parameter. Thatâ's not what I was asking. My question was how to write and
pass a 'where' clause specifically. What syntax to use.
For example: "WHERE EventDate = â'01/01/2007â' AND LocationCode = 'LA' AND zip
= 99874"
In that string, I have slashes, and quotes. When I try to pass this string
as a parameter, I get errors. Iâ've tried every type of â'escapeâ' technique
that I know and nothing works.
Thanks again.
--
Lucas Dargis
"Amarnath" wrote:
> Ok, to guide you precisly,
> If you have samples installed in your m/c, go to
> C:\Program Files\Microsoft SQL Server\90\Samples\Reporting
> Services\Extension Samples\FormsAuthentication Sample\cs (change folder name
> accordingly)
> you can see a custom security solution file, click on that and open. search
> for
> "AuthenticationExtension.cs" file and click on view code and search for
> "VerifyUser"
> In that code you can see how it is defined for stored procedure using
> commandtype
> and parameter.add is used. instead of "@.username" build your where clause by
> defining a variable and start adding all the conditions and pass it on using
> parameter.add.
> I think this should give some idea about how to write it.
> Please let me know if you have any problems
> Amarnath
>
> "akbikerboy" wrote:
> > there are a million articles about forms authentication. and i don't see what
> > that has to do with passing a where clause from an application to RS...
> >
> > thanks for trying though.
> > --
> > Lucas Dargis
> >
> >
> > "Amarnath" wrote:
> >
> > > Just go to search in online help and search for forms authentication and if
> > > you have installed the samples, go to the samples folder and see the forms
> > > authentication example code.
> > >
> > > Amarnath
> > >
> > > "akbikerboy" wrote:
> > >
> > > > I looked all over and i can't find what your are talking about. do you have a
> > > > link to it?
> > > > --
> > > > Lucas Dargis
> > > >
> > > >
> > > > "Amarnath" wrote:
> > > >
> > > > > sql server online help samples
> > > > >
> > > > > Amarnath
> > > > >
> > > > > "akbikerboy" wrote:
> > > > >
> > > > > > could you be more specific?
> > > > > > Are you talking about MSDN or in VS?
> > > > > > I can't find what you are talking about
> > > > > >
> > > > > >
> > > > > > thanks
> > > > > > --
> > > > > > Lucas Dargis
> > > > > >
> > > > > >
> > > > > > "Amarnath" wrote:
> > > > > >
> > > > > > > You have a very good sample available in samples. search for forms
> > > > > > > authentication and open the custom security c# file and see the code you will
> > > > > > > get good idea about how to write.
> > > > > > >
> > > > > > > Amarnath
> > > > > > >
> > > > > > > "akbikerboy" wrote:
> > > > > > >
> > > > > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > > > > in a c# application and then pass them as parameters to a report that would
> > > > > > > > be used by a SQL Server stored procedure.
> > > > > > > >
> > > > > > > > can anyone tell me how to do that?
> > > > > > > > Syntax for building it?
> > > > > > > > maybe a link to an example?
> > > > > > > >
> > > > > > > > thanks
> > > > > > > > --
> > > > > > > > Lucas Dargis|||Oh Ok, so you meant this. the same way, how you have used in the example,
with double quotes and single quotes. if doesnt work try concatenating some
thing like this. e.g "Where aa = " + " ' " + "01/01/2007" + " ' "
Let me know whether it is working ?
Amarnath
"akbikerboy" wrote:
> Well thanks for pointing that out precisely.
> I guess I should have been more specific. I know how to create and pass a
> parameter. Thatâ's not what I was asking. My question was how to write and
> pass a 'where' clause specifically. What syntax to use.
> For example: "WHERE EventDate = â'01/01/2007â' AND LocationCode = 'LA' AND zip
> = 99874"
> In that string, I have slashes, and quotes. When I try to pass this string
> as a parameter, I get errors. Iâ've tried every type of â'escapeâ' technique
> that I know and nothing works.
> Thanks again.
> --
> Lucas Dargis
>
> "Amarnath" wrote:
> > Ok, to guide you precisly,
> >
> > If you have samples installed in your m/c, go to
> >
> > C:\Program Files\Microsoft SQL Server\90\Samples\Reporting
> > Services\Extension Samples\FormsAuthentication Sample\cs (change folder name
> > accordingly)
> >
> > you can see a custom security solution file, click on that and open. search
> > for
> > "AuthenticationExtension.cs" file and click on view code and search for
> > "VerifyUser"
> >
> > In that code you can see how it is defined for stored procedure using
> > commandtype
> > and parameter.add is used. instead of "@.username" build your where clause by
> > defining a variable and start adding all the conditions and pass it on using
> > parameter.add.
> >
> > I think this should give some idea about how to write it.
> > Please let me know if you have any problems
> >
> > Amarnath
> >
> >
> > "akbikerboy" wrote:
> >
> > > there are a million articles about forms authentication. and i don't see what
> > > that has to do with passing a where clause from an application to RS...
> > >
> > > thanks for trying though.
> > > --
> > > Lucas Dargis
> > >
> > >
> > > "Amarnath" wrote:
> > >
> > > > Just go to search in online help and search for forms authentication and if
> > > > you have installed the samples, go to the samples folder and see the forms
> > > > authentication example code.
> > > >
> > > > Amarnath
> > > >
> > > > "akbikerboy" wrote:
> > > >
> > > > > I looked all over and i can't find what your are talking about. do you have a
> > > > > link to it?
> > > > > --
> > > > > Lucas Dargis
> > > > >
> > > > >
> > > > > "Amarnath" wrote:
> > > > >
> > > > > > sql server online help samples
> > > > > >
> > > > > > Amarnath
> > > > > >
> > > > > > "akbikerboy" wrote:
> > > > > >
> > > > > > > could you be more specific?
> > > > > > > Are you talking about MSDN or in VS?
> > > > > > > I can't find what you are talking about
> > > > > > >
> > > > > > >
> > > > > > > thanks
> > > > > > > --
> > > > > > > Lucas Dargis
> > > > > > >
> > > > > > >
> > > > > > > "Amarnath" wrote:
> > > > > > >
> > > > > > > > You have a very good sample available in samples. search for forms
> > > > > > > > authentication and open the custom security c# file and see the code you will
> > > > > > > > get good idea about how to write.
> > > > > > > >
> > > > > > > > Amarnath
> > > > > > > >
> > > > > > > > "akbikerboy" wrote:
> > > > > > > >
> > > > > > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > > > > > in a c# application and then pass them as parameters to a report that would
> > > > > > > > > be used by a SQL Server stored procedure.
> > > > > > > > >
> > > > > > > > > can anyone tell me how to do that?
> > > > > > > > > Syntax for building it?
> > > > > > > > > maybe a link to an example?
> > > > > > > > >
> > > > > > > > > thanks
> > > > > > > > > --
> > > > > > > > > Lucas Dargis|||so for the query i tried
select....
where @.where
parameter: LocationCode + "'" + LA + "'"
I am getting the following error
An error occurred whild executing the query
An expression of non-boolean type specified in a context where a condition
is expected, near @.where
error:4145
I am running the query in the report designed in the Data tab
thanks
--
Lucas Dargis
"akbikerboy" wrote:
> I want to build a SQL WHERE (and possibly ORDER BY) clause
> in a c# application and then pass them as parameters to a report that would
> be used by a SQL Server stored procedure.
> can anyone tell me how to do that?
> Syntax for building it?
> maybe a link to an example?
> thanks
> --
> Lucas Dargis|||For the query i use
SELECT...
WHERE @.where
parameter: declared as a string
LocationCode = + "'" + LA + "'"
and i got the following error:
An error occurred whild executing the query.
An expression of non-boolean type specified in a contex where a condition is
expected, near '@.where'.
Error: 4145
I am running the query in the Data tab in the Report Builder
thanks
--
Lucas Dargis
"Amarnath" wrote:
> Oh Ok, so you meant this. the same way, how you have used in the example,
> with double quotes and single quotes. if doesnt work try concatenating some
> thing like this. e.g "Where aa = " + " ' " + "01/01/2007" + " ' "
> Let me know whether it is working ?
> Amarnath
> "akbikerboy" wrote:
> > Well thanks for pointing that out precisely.
> >
> > I guess I should have been more specific. I know how to create and pass a
> > parameter. Thatâ's not what I was asking. My question was how to write and
> > pass a 'where' clause specifically. What syntax to use.
> >
> > For example: "WHERE EventDate = â'01/01/2007â' AND LocationCode = 'LA' AND zip
> > = 99874"
> >
> > In that string, I have slashes, and quotes. When I try to pass this string
> > as a parameter, I get errors. Iâ've tried every type of â'escapeâ' technique
> > that I know and nothing works.
> >
> > Thanks again.
> >
> > --
> > Lucas Dargis
> >
> >
> > "Amarnath" wrote:
> >
> > > Ok, to guide you precisly,
> > >
> > > If you have samples installed in your m/c, go to
> > >
> > > C:\Program Files\Microsoft SQL Server\90\Samples\Reporting
> > > Services\Extension Samples\FormsAuthentication Sample\cs (change folder name
> > > accordingly)
> > >
> > > you can see a custom security solution file, click on that and open. search
> > > for
> > > "AuthenticationExtension.cs" file and click on view code and search for
> > > "VerifyUser"
> > >
> > > In that code you can see how it is defined for stored procedure using
> > > commandtype
> > > and parameter.add is used. instead of "@.username" build your where clause by
> > > defining a variable and start adding all the conditions and pass it on using
> > > parameter.add.
> > >
> > > I think this should give some idea about how to write it.
> > > Please let me know if you have any problems
> > >
> > > Amarnath
> > >
> > >
> > > "akbikerboy" wrote:
> > >
> > > > there are a million articles about forms authentication. and i don't see what
> > > > that has to do with passing a where clause from an application to RS...
> > > >
> > > > thanks for trying though.
> > > > --
> > > > Lucas Dargis
> > > >
> > > >
> > > > "Amarnath" wrote:
> > > >
> > > > > Just go to search in online help and search for forms authentication and if
> > > > > you have installed the samples, go to the samples folder and see the forms
> > > > > authentication example code.
> > > > >
> > > > > Amarnath
> > > > >
> > > > > "akbikerboy" wrote:
> > > > >
> > > > > > I looked all over and i can't find what your are talking about. do you have a
> > > > > > link to it?
> > > > > > --
> > > > > > Lucas Dargis
> > > > > >
> > > > > >
> > > > > > "Amarnath" wrote:
> > > > > >
> > > > > > > sql server online help samples
> > > > > > >
> > > > > > > Amarnath
> > > > > > >
> > > > > > > "akbikerboy" wrote:
> > > > > > >
> > > > > > > > could you be more specific?
> > > > > > > > Are you talking about MSDN or in VS?
> > > > > > > > I can't find what you are talking about
> > > > > > > >
> > > > > > > >
> > > > > > > > thanks
> > > > > > > > --
> > > > > > > > Lucas Dargis
> > > > > > > >
> > > > > > > >
> > > > > > > > "Amarnath" wrote:
> > > > > > > >
> > > > > > > > > You have a very good sample available in samples. search for forms
> > > > > > > > > authentication and open the custom security c# file and see the code you will
> > > > > > > > > get good idea about how to write.
> > > > > > > > >
> > > > > > > > > Amarnath
> > > > > > > > >
> > > > > > > > > "akbikerboy" wrote:
> > > > > > > > >
> > > > > > > > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > > > > > > > in a c# application and then pass them as parameters to a report that would
> > > > > > > > > > be used by a SQL Server stored procedure.
> > > > > > > > > >
> > > > > > > > > > can anyone tell me how to do that?
> > > > > > > > > > Syntax for building it?
> > > > > > > > > > maybe a link to an example?
> > > > > > > > > >
> > > > > > > > > > thanks
> > > > > > > > > > --
> > > > > > > > > > Lucas Dargis|||By two way you can solve this.
1. use stored proc to concatenate all the "select", includng the values
which comes from parameter ie where clause
2. By directly giving in the data tab..
e.g I have taken some samples from adventure... it goes like this..
paste this code in the data tab it executes successfully..
declare @.s as nvarchar(1000)
set @.s = 'SELECT ContactID, NameStyle, Title, FirstName, FROM
Person.Contact WHERE ' + @.w
exec sp_executesql @.s
the @.w is what I entered " as (Title = 'Mr.').
PS. "where", is the reserved word, so name @.where to some other name.
So basically what i meant here is to built using stored proc or use string
and concatenate with your parameter.
Amarnath
"akbikerboy" wrote:
> so for the query i tried
> select....
> where @.where
> parameter: LocationCode + "'" + LA + "'"
> I am getting the following error
> An error occurred whild executing the query
> An expression of non-boolean type specified in a context where a condition
> is expected, near @.where
> error:4145
> I am running the query in the report designed in the Data tab
> thanks
> --
> Lucas Dargis
>
> "akbikerboy" wrote:
> > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > in a c# application and then pass them as parameters to a report that would
> > be used by a SQL Server stored procedure.
> >
> > can anyone tell me how to do that?
> > Syntax for building it?
> > maybe a link to an example?
> >
> > thanks
> > --
> > Lucas Dargis|||AWESOME! very clever.
well your second solution is just what i was looking for, however, it brings
up another problem.
Since the query is now created in a variable, RS doesn't recognize the
fields in the layout tab. how do i reference the fields so i can create the
report?
thanks again
--
Lucas Dargis
"Amarnath" wrote:
> By two way you can solve this.
> 1. use stored proc to concatenate all the "select", includng the values
> which comes from parameter ie where clause
> 2. By directly giving in the data tab..
> e.g I have taken some samples from adventure... it goes like this..
> paste this code in the data tab it executes successfully..
> declare @.s as nvarchar(1000)
> set @.s = 'SELECT ContactID, NameStyle, Title, FirstName, FROM
> Person.Contact WHERE ' + @.w
> exec sp_executesql @.s
> the @.w is what I entered " as (Title = 'Mr.').
> PS. "where", is the reserved word, so name @.where to some other name.
> So basically what i meant here is to built using stored proc or use string
> and concatenate with your parameter.
> Amarnath
>
> "akbikerboy" wrote:
> > so for the query i tried
> > select....
> > where @.where
> >
> > parameter: LocationCode + "'" + LA + "'"
> >
> > I am getting the following error
> >
> > An error occurred whild executing the query
> > An expression of non-boolean type specified in a context where a condition
> > is expected, near @.where
> >
> > error:4145
> >
> > I am running the query in the report designed in the Data tab
> >
> > thanks
> > --
> > Lucas Dargis
> >
> >
> > "akbikerboy" wrote:
> >
> > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > in a c# application and then pass them as parameters to a report that would
> > > be used by a SQL Server stored procedure.
> > >
> > > can anyone tell me how to do that?
> > > Syntax for building it?
> > > maybe a link to an example?
> > >
> > > thanks
> > > --
> > > Lucas Dargis|||So you can forget my last question. I reread your last post and figured it out.
i put the sql code you provided me into a stored proc and called that proc
while sending the Where Clause as a parameter and it worked PERFECTLY!!!
i can't thank you enough. i've been stuck on this for a few weeks.
Lucas Dargis
"akbikerboy" wrote:
> AWESOME! very clever.
> well your second solution is just what i was looking for, however, it brings
> up another problem.
> Since the query is now created in a variable, RS doesn't recognize the
> fields in the layout tab. how do i reference the fields so i can create the
> report?
> thanks again
> --
> Lucas Dargis
>
> "Amarnath" wrote:
> > By two way you can solve this.
> > 1. use stored proc to concatenate all the "select", includng the values
> > which comes from parameter ie where clause
> > 2. By directly giving in the data tab..
> > e.g I have taken some samples from adventure... it goes like this..
> >
> > paste this code in the data tab it executes successfully..
> >
> > declare @.s as nvarchar(1000)
> > set @.s = 'SELECT ContactID, NameStyle, Title, FirstName, FROM
> > Person.Contact WHERE ' + @.w
> > exec sp_executesql @.s
> >
> > the @.w is what I entered " as (Title = 'Mr.').
> >
> > PS. "where", is the reserved word, so name @.where to some other name.
> > So basically what i meant here is to built using stored proc or use string
> > and concatenate with your parameter.
> >
> > Amarnath
> >
> >
> > "akbikerboy" wrote:
> >
> > > so for the query i tried
> > > select....
> > > where @.where
> > >
> > > parameter: LocationCode + "'" + LA + "'"
> > >
> > > I am getting the following error
> > >
> > > An error occurred whild executing the query
> > > An expression of non-boolean type specified in a context where a condition
> > > is expected, near @.where
> > >
> > > error:4145
> > >
> > > I am running the query in the report designed in the Data tab
> > >
> > > thanks
> > > --
> > > Lucas Dargis
> > >
> > >
> > > "akbikerboy" wrote:
> > >
> > > > I want to build a SQL WHERE (and possibly ORDER BY) clause
> > > > in a c# application and then pass them as parameters to a report that would
> > > > be used by a SQL Server stored procedure.
> > > >
> > > > can anyone tell me how to do that?
> > > > Syntax for building it?
> > > > maybe a link to an example?
> > > >
> > > > thanks
> > > > --
> > > > Lucas Dargis

No comments:

Post a Comment