Showing posts with label define. Show all posts
Showing posts with label define. Show all posts

Friday, March 23, 2012

Parameter as Column Name?

Greetings,

I am developing a search form that uses a DDL to select a column name and a text box to define a search term. Code follows:

1cmdSearch = New SqlCommand( "select * from sites where @.columnName like @.sTerm order by site_name", conSites)23cmdSearch.Parameters.Add( "@.columnName", SqlDbType.Text).Value=ColumnParam4cmdSearch.Parameters.Add( "@.sTerm", SqlDbType.Text).Value=searchParam

The problem I'm running into is that the @.variable appears to imply single quotes about the value. This is fine for @.sTerm, I just removed the quotes from the concatenation and it reads the value correctly, but it appears to break @.columnName and the query returns no values.

If I manually substitute an appropriate column for @.columnName sans single quotes, it works.

How can I eliminate the implied single quotes from @.columnName so that the query will read it properly?

You need to build your statement dynamically within your xp and execute it using sp_executesql system stored procedure. (Don't use the column variable in your sql.)

You should create a stored procedure to handle the building and execution of the string to make the process easier and reusable. Use parameters (like you did in your current sql statement, just not for a column or table name) to prevent injection attacks.

http://msdn2.microsoft.com/en-us/library/ms175170.aspx

|||

Thanks for the advice, but I can't use stored procedures for this project, or I would've done it that way from the beginning.

Is there any way to define the @.variable to eliminate the implied quotes?

ps2goat:

You need to build your statement dynamically within your xp and execute it using sp_executesql system stored procedure. (Don't use the column variable in your sql.)

You should create a stored procedure to handle the building and execution of the string to make the process easier and reusable. Use parameters (like you did in your current sql statement, just not for a column or table name) to prevent injection attacks.

http://msdn2.microsoft.com/en-us/library/ms175170.aspx

|||

You can build the SQL dynamically with the column name, but still keep parameters for everything else. This will still limit sql injections.

A quick example:

cmdSearch =New SqlCommand("select * from sites where " & ColumnParam &" like @.sTerm order by site_name", conSites)' continue with code as normal, but no column parameter.
|||

Thanks, this did the trick. I'd tried doing it this way before but couldn't work out the syntax.

Much obliged.

ps2goat:

You can build the SQL dynamically with the column name, but still keep parameters for everything else. This will still limit sql injections.

A quick example:

cmdSearch =New SqlCommand("select * from sites where " & ColumnParam &" like @.sTerm order by site_name", conSites)' continue with code as normal, but no column parameter.

sql

Saturday, February 25, 2012

Page Size

Hi,
In crystal reports, I can define page size (letter size or legal size) and
page orientation (Langscap or Prortrait) so the preview exactly looks like
the final print.
Is it possible to do that in MSRS?
To re-word the question, How can I define the page size (letter size or
legal size) and page orientation (Langscap or Prortrait) at design time in
Microsoft Reporting services ?
Thank you,
AlanIn VSNET, open a report in designer, click menu "Report->Report
Properties...", then "Layout" tab.
"A.M" <nospam1@.online.nospam> wrote in message
news:e5y7M7KoEHA.1308@.TK2MSFTNGP14.phx.gbl...
> Hi,
> In crystal reports, I can define page size (letter size or legal size) and
> page orientation (Langscap or Prortrait) so the preview exactly looks like
> the final print.
> Is it possible to do that in MSRS?
> To re-word the question, How can I define the page size (letter size or
> legal size) and page orientation (Langscap or Prortrait) at design time in
> Microsoft Reporting services ?
> Thank you,
> Alan
>
>

Page Size

Hi,
How can I define Page Size.Orientation in Report Designer?
I am looking for some way to define letter/legal size paper and also
Landescap/Portrate paper orientation.
Can users change those printig attributes when they are printing/expoting
that to PDF file?
Thank,
AlanYou can change the page width and page height to 11 x 8.5 instead of 8.5 x
11 inches in the report designer. You can find these properties in the
Report | "Report Properties..." menu item, select the Layout tab.
A user can change the Rendering attributes when they view a report via the
ReportServer web service. For example, to retrieve a PDF report rendered
with a height of 15 inches instead of the default 11 inches, a user would
use this URL:
http://servername/ReportServer?/Project1/Test_Report1&rs:Command=Render&rs:F
ormat=PDF&rc:PageHeight=15in
The user's printer settings is up to them but it would look best if the
rendering parameters match the printer parameters. For more information
see the Reporting Services Device Information Settings page on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/
rsp_prog_soapapi_dev_5l7q.asp?frame=true
Jonathan Kyle, MCSD
Microsoft WebData Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
--
>From: "A.M" <nospam1@.online.nospam>
>Subject: Page Size
>Date: Tue, 7 Sep 2004 13:42:04 -0400
>Lines: 14
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
>Message-ID: <#MFqkGQlEHA.3520@.TK2MSFTNGP11.phx.gbl>
>Newsgroups: microsoft.public.sqlserver.reportingsvcs
>NNTP-Posting-Host: 209.226.40.154
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11