Showing posts with label displaying. Show all posts
Showing posts with label displaying. Show all posts

Monday, February 13, 2012

ASP.NET ReportViewer / Non-String parameters

I am displaying a local report in a ReportViewer control on an asp.net web page. My report contains non-string parameters. How can i set a non-string parameter value on a local report?You will need to call .ToString() on your value to set it on ReportParameter.|||That would result in a string being passed to the report. I want to pass a float or a datetime to the report.

The only way i've been able to get this to work is to create a typed dataset with the "parameters" i want sent and then use aggregation functions (first,sum, etc...) to get to the data into the report. That is a big workaround in order to get a few simple floats and times into my report. Has anyone been able to get this done using another method?
|||If the data type of the parameter is set to integer/float, you can do these operations. And you can always convert between types in a report expression.

Sunday, February 12, 2012

ASP.Net and MS SQL

Dreamweaver MX and ASP.Net and MS SQL

I am displaying a page of lists of addresses based on state.

.../results.aspx?state=id

I want to add a little "re-sort" links. For example: sort by | name | city | style

.../results.aspx?state=id&sort=city
(if sort is missing default to "sort=name")

But I a having a problems... here is part of my code, following dreamwevers standards for ASP.Net -

CommandText='<%# "SELECT * FROM tblRestaurants WHERE ""State"" = @.State ORDER BY @.Sort ASC" %>'

<parameters>
<parameter name="@.State" value='<%# IIf((Request.QueryString("state") <> Nothing), Request.QueryString("state"), "") %>' type="VarChar" />
<parameter name="@.Sort" value='<%# IIf((Request.QueryString("sort") <> Nothing), Request.QueryString("sort"), "name") %>' type="VarChar" />
</parameters
But "@.Sort" is causing errors, I think @. is a reserved keyword in MS SQL (?),
here is the error message -

System.Data.SqlClient.SqlException: The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name.

I have tried to change @.Sort about a dozen different names "MMSort", "urlSort" etc.
here is the error message -

System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'urlSort'.

One side note, I displaying the results in a repeating datalist, a datagrid is out.
A rough draft version without working sort is at
http://www.jbmcgregor.com/cira/results.aspx?state=id

Any suggestion, ideas or help would be extremely appreciated. Thanks.

DanielIt would help if you provide the actual sql query that gets executed. Use Try...Catch to catch the exception and use response.write to figure out exactly what was the sql command that gets executed. Probably it is a systax error.