Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Friday, March 30, 2012

How to value parameters for sqldatasource

I set up a sqldatasource based on a stored procedure which takes one parameter. The sqldatasrouce wizard generates the following code for the parameter below. The question is how do I value the DeptID parameter on the load of the form. I tried the following code in the load of the page, but get a null reference error:

Me.SqlDataSource1.InsertParameters("DeptID").DefaultValue = Session("DeptID")

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:FDConn %>"
SelectCommand="GetTruckStatus" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="DeptID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<radG:RadGrid ID="RadGrid1" runat="server">
</radG:RadGrid>

You've set the value of an InsertParameter, but you are performing a Select, not an Insert. Anyway, the SqlDataSource offers a number of different parameter types. One of them is an <asp:SessionParameter>. Use that instead of the generic<asp:Parameter> that you are currently using. You can reconfigure the SqlDataSource to generate it automatically. Click the WHERE button when applying the Select Statement, and in the Source dropdown, choose Session.

|||

Mike,
Thanks for the information. I went back into the configure the sqldatasrouce, but if you chose to use a stored procedure, the button for selecting "Where" is grayed out. I assumed that since the code was generated from vb and from the stored procedure I selected, vb would know the type of parameter it had to generate.


Regards,
Tom

|||

Mike,

I went back into the code and used the "SelectParameter" type and all worked well. Thanks for pointing me in the right direction.

Tom

Wednesday, March 28, 2012

How to validate the parameter values?

Hi,

Is there any way to validate the input paratemers for the report? For example: I want to restrict the value to be less than 100 in one parameter. How to achieve this?

Thnx in advance.

There is no way to validate and inform the user if the parameter value is not in a given range. Though you can restrict the values that user can select for the parameter by providing pre-defined available values to the parameter, either from query or non-queried.

Shyam

|||

Pre-defining the values will be helpful in case of numeric or string values. What if i want to compare date values. For example:

given date is less than or equal to today's date... I think, this is also not possible!!!

The RS Engine validates the date based on the format only. The validations are not possible.

Some alternative should be thought-of by microsoft... as validations are very necessary.

How to Using Variable in OPENROWSET T-SQL

Hi,
How to use variable as parameter in stored procedure using OPENROWSET
'
I try the query below, but get an error. Please help me.
DECLARE @.job varchar(5)
SET @.job='RefreshTLMReport'
SELECT *
FROM
OPENROWSET('sqloledb'
, 'server=reportsvr;trusted_connection=yes
'
, 'set fmtonly off exec msdb..sp_help_job @.job_name='
+ @.job + ')'
ThanksResant
declare @.par int,@.sql varchar(8000)
set @.par=1
set @.sql ='exec mysp ' + cast(@.par as varchar(10))+''''
EXEC ('select *
from
OPENROWSET(''SQLOLEDB'',''SERVER=name;DA
TABASE=pubs;UID=sa;PWD=pass;'',''set
fmtonly off; ' + @.sql+')')
"Resant" <resant_v@.yahoo.com> wrote in message
news:1131512827.293294.303190@.g44g2000cwa.googlegroups.com...
> Hi,
> How to use variable as parameter in stored procedure using OPENROWSET
> '
> I try the query below, but get an error. Please help me.
> DECLARE @.job varchar(5)
> SET @.job='RefreshTLMReport'
> SELECT *
> FROM
> OPENROWSET('sqloledb'
> , 'server=reportsvr;trusted_connection=yes
'
> , 'set fmtonly off exec msdb..sp_help_job @.job_name='
> + @.job + ')'
>
> Thanks
>|||Hi
sp_help_job will not return a single resultset therefore you can't use it in
OPENQUERY. Your code is also truncating the jobname to 5 characters. Try
DECLARE @.job sysname
SET @.job='RefreshTLMReport'
EXEC reportsvr.msdb..sp_help_job @.job_name=@.job
John
"Resant" wrote:

> Hi,
> How to use variable as parameter in stored procedure using OPENROWSET
> '
> I try the query below, but get an error. Please help me.
> DECLARE @.job varchar(5)
> SET @.job='RefreshTLMReport'
> SELECT *
> FROM
> OPENROWSET('sqloledb'
> , 'server=reportsvr;trusted_connection=yes
'
> , 'set fmtonly off exec msdb..sp_help_job @.job_name='
> + @.job + ')'
>
> Thanks
>|||I think it's much better, but thanks all.
DECLARE @.job varchar(5)
SET @.job='RefreshTLMReport'
SELECT *
FROM
OPENROWSET('sqloledb'
, 'server=reportsvr;trusted_connection=yes
'
, 'set fmtonly off exec msdb..sp_help_job')
WHERE name=@.job|||Hi Resant
This will produce different results to running it directly and specifying
the @.job_name!
You have still declared @.job as varchar(5) instead of a sysname.
John
"Resant" wrote:

> I think it's much better, but thanks all.
> DECLARE @.job varchar(5)
> SET @.job='RefreshTLMReport'
> SELECT *
> FROM
> OPENROWSET('sqloledb'
> , 'server=reportsvr;trusted_connection=yes
'
> , 'set fmtonly off exec msdb..sp_help_job')
> WHERE name=@.job
>sql

Monday, March 26, 2012

how to use use <db name> in store procedure

Hi
I am passing database name as a parameter in the stored procedure
I want to create stored procedure in master and want to access the database
systables depending on the input to the stored procedure.
How do I go in that specific database as I can not use "use @.dbname"
in store procedure.
Thanks
MangeshMangesh Deshpande wrote:
> Hi
> I am passing database name as a parameter in the stored procedure
> I want to create stored procedure in master and want to access the
> database systables depending on the input to the stored procedure.
> How do I go in that specific database as I can not use "use @.dbname"
> in store procedure.
> Thanks
> Mangesh
The easiest way is probably to use dynamic SQL. Just be really careful
of SQL Injection issues. Make sure the procedure does adequate data
validation.
Creating procedures in master is not recommended. For one reason, they
may disappear with service pack installations. I think you're better off
creating a shared database to store all your "shared" procedures.
Microsoft does this in SQL Server with the msdb database. It just
requires using the database name when executing the procedure.
-- Dynamic SQL
Declare @.n nvarchar(1000)
Declare @.db nvarchar(128)
Set @.db = N'[pubs]'
Set @.n = N'Select * from ' + @.db + N'.[dbo].[sysobjects]'
Exec sp_executesql @.n
David Gugick
Imceda Software
www.imceda.com|||Thanks David.
Is there a best practices document you know of for coding in sqlserver?
"David Gugick" wrote:
> Mangesh Deshpande wrote:
> > Hi
> >
> > I am passing database name as a parameter in the stored procedure
> > I want to create stored procedure in master and want to access the
> > database systables depending on the input to the stored procedure.
> >
> > How do I go in that specific database as I can not use "use @.dbname"
> > in store procedure.
> >
> > Thanks
> > Mangesh
> The easiest way is probably to use dynamic SQL. Just be really careful
> of SQL Injection issues. Make sure the procedure does adequate data
> validation.
> Creating procedures in master is not recommended. For one reason, they
> may disappear with service pack installations. I think you're better off
> creating a shared database to store all your "shared" procedures.
> Microsoft does this in SQL Server with the msdb database. It just
> requires using the database name when executing the procedure.
>
> -- Dynamic SQL
> Declare @.n nvarchar(1000)
> Declare @.db nvarchar(128)
> Set @.db = N'[pubs]'
> Set @.n = N'Select * from ' + @.db + N'.[dbo].[sysobjects]'
> Exec sp_executesql @.n
>
> --
> David Gugick
> Imceda Software
> www.imceda.com
>sql

how to use use <db name> in store procedure

Hi
I am passing database name as a parameter in the stored procedure
I want to create stored procedure in master and want to access the database
systables depending on the input to the stored procedure.
How do I go in that specific database as I can not use "use @.dbname"
in store procedure.
Thanks
Mangesh
Mangesh Deshpande wrote:
> Hi
> I am passing database name as a parameter in the stored procedure
> I want to create stored procedure in master and want to access the
> database systables depending on the input to the stored procedure.
> How do I go in that specific database as I can not use "use @.dbname"
> in store procedure.
> Thanks
> Mangesh
The easiest way is probably to use dynamic SQL. Just be really careful
of SQL Injection issues. Make sure the procedure does adequate data
validation.
Creating procedures in master is not recommended. For one reason, they
may disappear with service pack installations. I think you're better off
creating a shared database to store all your "shared" procedures.
Microsoft does this in SQL Server with the msdb database. It just
requires using the database name when executing the procedure.
-- Dynamic SQL
Declare @.n nvarchar(1000)
Declare @.db nvarchar(128)
Set @.db = N'[pubs]'
Set @.n = N'Select * from ' + @.db + N'.[dbo].[sysobjects]'
Exec sp_executesql @.n
David Gugick
Imceda Software
www.imceda.com
|||Thanks David.
Is there a best practices document you know of for coding in sqlserver?
"David Gugick" wrote:

> Mangesh Deshpande wrote:
> The easiest way is probably to use dynamic SQL. Just be really careful
> of SQL Injection issues. Make sure the procedure does adequate data
> validation.
> Creating procedures in master is not recommended. For one reason, they
> may disappear with service pack installations. I think you're better off
> creating a shared database to store all your "shared" procedures.
> Microsoft does this in SQL Server with the msdb database. It just
> requires using the database name when executing the procedure.
>
> -- Dynamic SQL
> Declare @.n nvarchar(1000)
> Declare @.db nvarchar(128)
> Set @.db = N'[pubs]'
> Set @.n = N'Select * from ' + @.db + N'.[dbo].[sysobjects]'
> Exec sp_executesql @.n
>
> --
> David Gugick
> Imceda Software
> www.imceda.com
>

how to use use <db name> in store procedure

Hi
I am passing database name as a parameter in the stored procedure
I want to create stored procedure in master and want to access the database
systables depending on the input to the stored procedure.
How do I go in that specific database as I can not use "use @.dbname"
in store procedure.
Thanks
MangeshMangesh Deshpande wrote:
> Hi
> I am passing database name as a parameter in the stored procedure
> I want to create stored procedure in master and want to access the
> database systables depending on the input to the stored procedure.
> How do I go in that specific database as I can not use "use @.dbname"
> in store procedure.
> Thanks
> Mangesh
The easiest way is probably to use dynamic SQL. Just be really careful
of SQL Injection issues. Make sure the procedure does adequate data
validation.
Creating procedures in master is not recommended. For one reason, they
may disappear with service pack installations. I think you're better off
creating a shared database to store all your "shared" procedures.
Microsoft does this in SQL Server with the msdb database. It just
requires using the database name when executing the procedure.
-- Dynamic SQL
Declare @.n nvarchar(1000)
Declare @.db nvarchar(128)
Set @.db = N'[pubs]'
Set @.n = N'Select * from ' + @.db + N'.[dbo].[sysobjects]'
Exec sp_executesql @.n
David Gugick
Imceda Software
www.imceda.com|||Thanks David.
Is there a best practices document you know of for coding in sqlserver?
"David Gugick" wrote:

> Mangesh Deshpande wrote:
> The easiest way is probably to use dynamic SQL. Just be really careful
> of SQL Injection issues. Make sure the procedure does adequate data
> validation.
> Creating procedures in master is not recommended. For one reason, they
> may disappear with service pack installations. I think you're better off
> creating a shared database to store all your "shared" procedures.
> Microsoft does this in SQL Server with the msdb database. It just
> requires using the database name when executing the procedure.
>
> -- Dynamic SQL
> Declare @.n nvarchar(1000)
> Declare @.db nvarchar(128)
> Set @.db = N'[pubs]'
> Set @.n = N'Select * from ' + @.db + N'.[dbo].[sysobjects]'
> Exec sp_executesql @.n
>
> --
> David Gugick
> Imceda Software
> www.imceda.com
>

How to use the same stored procedure to display two different char

I need to display two charts on a report based on the same stored procedure
that accepts a single parameter. I do not wish to be promted for the
parameter. Instead, I would like to pass two different values to each chart
within the report.
Please advise.
Thanks,
KonstantinHow do you know what value to pass it?
Anyway, something to get you going in the right direction. First thing to
realize is that query parameters and report parameters are two different
things. RS automatically creates a report parameter for you for each stored
procedure query parameter it sees. But, you don't have to use it. You can
map it to an expression instead. Click on the ..., parameters tab. On the
right pick change it from mapping to a report parameter and map it to an
expression instead.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Konstantin Shaumyan" <KonstantinShaumyan@.discussions.microsoft.com> wrote
in message news:3A7E2C6B-FF43-4993-9B21-04EA79316410@.microsoft.com...
>I need to display two charts on a report based on the same stored procedure
> that accepts a single parameter. I do not wish to be promted for the
> parameter. Instead, I would like to pass two different values to each
> chart
> within the report.
> Please advise.
> Thanks,
> Konstantin|||Thanks for the tip.
I created two datasets based on the same stored procedure for each graph and
set my parameter for each dataset to literals.
Everything worked as expected.
Regards,
Konstantin
"Bruce L-C [MVP]" wrote:
> How do you know what value to pass it?
> Anyway, something to get you going in the right direction. First thing to
> realize is that query parameters and report parameters are two different
> things. RS automatically creates a report parameter for you for each stored
> procedure query parameter it sees. But, you don't have to use it. You can
> map it to an expression instead. Click on the ..., parameters tab. On the
> right pick change it from mapping to a report parameter and map it to an
> expression instead.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Konstantin Shaumyan" <KonstantinShaumyan@.discussions.microsoft.com> wrote
> in message news:3A7E2C6B-FF43-4993-9B21-04EA79316410@.microsoft.com...
> >I need to display two charts on a report based on the same stored procedure
> > that accepts a single parameter. I do not wish to be promted for the
> > parameter. Instead, I would like to pass two different values to each
> > chart
> > within the report.
> >
> > Please advise.
> >
> > Thanks,
> > Konstantin
>
>sql

Wednesday, March 21, 2012

How to use set_ParameterField to pass a parameter to a report

I have to pass a dateTime to a Report
I try to use this code

AxCrystalReport1.set_ParameterFields(0, "START;CDate(28/04/2005 0.00.00);True")
or this
AxCrystalReport1.set_ParameterFields(0, "START;CDate(28/04/2005);True")
and also
AxCrystalReport1.set_ParameterFields(0, "START;28/04/2005;True")

But in all the case report doesn't appear to video...

I'm sure that there isn't any error in the rest of code , the problem is on this line !!

where's my mistake?
Please
Help me...If you are using Vb.Net then use the following code

'Declare these 3 objects
Dim p1 As New ParameterFields
Dim p2 As New ParameterField
Dim p3 As New ParameterDiscreteValue

'Now set the name of your parameter to the 'ParameterField' object

p2.ParameterFieldName = "Header" ' replace "Header" with the name of your Parameter

'Now set the needed value to the 'ParameterDiscreteValue' Object
p3.Value = "Country Report2"
'Now add that value to ParameterField Object
p2.CurrentValues.Add(p3)
'Bind the ParameterField obj to ParameterFields obj
p1.Add(p2)
'Now set the ParameterFields obj to report
frm1.crv1.ParameterFieldInfo = p1 'Here crv1 is the crystal report Obj

Think that works for you|||Thanks I try also your solution ... it' s works well!!

but my initial problem was also passing date ( with time eventually) parameter...
And yesterday night I 've find a good solution ... I just substitute Cdate with Date and the passing Date parameter goes well!!

Anyway See ya & thks a lot!!!|||how to pass multiple parameter with this method?

i was using

Rep.SetParameterValue("n_socio", nSocio)
Rep.SetParameterValue("tipo_socio", sTipoSocio)
Rep.SetParameterValue("dni", dni)
....

to pass multiple parameters to crystal reports but when i upgrade CR from Ver. 9 to Ver. 10 this method don't work anymore.

please help...sql

Monday, March 19, 2012

how to use parameters in method (filter by parameter)

Hello!

I've begin to do a tutorial of this site: Working with Data in ASP.NET 2.0 c#, but in the 3. step I can't make something:

In this step I can't add parameterized methods to the TableAdapter. The problem come up when I want to add Sql query.

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID = @.CategoryID

The error message:

Error in WHERE clause near'@.'.
Unable to parse query text.

So, how can i use parameter in this method?

tnx for the help

Simpson

Are you sure you are passing in the parameter values to the TableAdapter when calling in your code?

Thanks

|||Hi

I have the same problem have you found a solution.

Regards
Demetrios|||Hi

I have the same problem have you found a solution.

Regards
Demetrios|||Hi

I have the same problem have you found a solution.

Regards
Demetrios|||

Hi MaoBranca,

This might because the @.CategoryID was not declared properly.

If this is a SQL Server database, please make sure that you have added the parameter to the SqlCommand parameter collection. If it has been added, please also confirm that the data type, size and value are correct.

HTH. If this does not answer you question, please feel free to mark it as Not Answered and post your reply. Thanks!

|||i have found the solution

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID = @.CategoryID

this works for sqlserver if you are using an access database then it is

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID = ?

if you are using mysql then it is

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID = #CategoryID

but i an not sure with mysql

How to use parameters

iam developing the crystal report there was small problem iam facing
please help me
How to use parameter of main report into the subreport
example
@.startdatetime is a parameter in main report
ia want to use the same parmeter in subreportcreate startdatetime parameter in subreport as well, then like it with main reports parameter.

i think i already suggested this to you.|||Thanks for reply

But we are getting six parameter while running the report
six parameters are
3 from sub reports(@.agencyid,@.startdatetime,@.Enddatetime)
3 from main reports(@.agencyid,@.startdatetime,@.Enddatetime)

while running the report it asking for
@.agencyid for subreport name
@.startdatetime for subreport name
@.Enddatetime for subreport name
@.agencyid
@.startdatetime
@.Enddatetime

but i requried only three parameter to be displayed to enter the values
please suggest me to solve the problem|||yes after linking it will ask only for main report parameters.|||You can make use of shared variables. Read it in help file

How to use parameter with LIKE?

Hello.
I have a query that ends like this:

WHERE ID LIKE '12345%'

I want to replace the '12345' with a parameter name p_id.
If I'm useing only p_id without the % it ok but if I'm useing the % after the parameter I'm getting an error.

I'm working ORACLE database.

Any ideas?

Thanks in advance,
Roy.

try this

WHERE ID LIKE :your_parameter + "%"

|||

Or, if using native Oracle vs. OLE/DB:

Where ID Like :your_parameter || '%'

Hope this helps,

Don Shelman

How to use parameter with LIKE?

Hello.
I have a query that ends like this:
WHERE ID LIKE '12345%'
I want to replace the '12345' with a parameter name p_id.
If I'm useing only p_id without the % it ok but if I'm useing the %
after the parameter I'm getting an error.
I'm working ORACLE database.
Any ideas?
Thanks in advance,
Roy.try this
="where id like '" & p_id & "%'"
"nicknack" wrote:
> Hello.
> I have a query that ends like this:
> WHERE ID LIKE '12345%'
> I want to replace the '12345' with a parameter name p_id.
> If I'm useing only p_id without the % it ok but if I'm useing the %
> after the parameter I'm getting an error.
> I'm working ORACLE database.
> Any ideas?
> Thanks in advance,
> Roy.
>

how to use parameter value as a column name

I am feeding in @.RsCategory varchar (25) into my stored procedure. I was hoping to make the RsCategory = the column name from the table I would like to select data from.

How can I use @.RscCategory as the column name value in the select statement? (or can I?)

select @.RsCategory as displaydata

From tTable T

where T.MyOtherParams=@.MyOtherParams

Any help would be greatly appreciated!

One way is to use dynamic SQL

DELCARE @.strSQL = 'SELECT ' + @.RsCategory + 'AS displaydata FROM tTable T WHERE MyOtherParam=' + @.MyOtherParams

EXEC @.strSQL

|||

You got the answer to your question. But what are you trying to do actually by sending the column name to be selected from client side? You can either write different SELECT statements in your SP or return the minimal data that you need and let the client hide the columns based on the configuration. Using dynamic SQL is simple but it has lot of security and maintainence issues. For example, the posted code doesn't protect against SQL injection attacks. You can do that by using QUOTENAME on the passed column name parameter.

An alternative approach is to use CASE expression as shown below which will work if the columns are compatible data types:

select case @.RscCategory

when 'Col1' then t.Col1

when 'Col2' then t.Col2

end as displaydata

How to use Parameter Query for SQL IN staetement

I run into a problem to use prameter query for IN statement
Declare @.bID varchar(20)
set @.bID='1,2'
SELECT * FROM test WHERE ID IN(@.data)
Is there a solution?You are almost there

Declare @.bID varchar(20)
set @.bID='1,2'
print('SELECT * FROM a WHERE ID IN('+@.bid+')')
exec('SELECT * FROM a WHERE ID IN('+@.bid+')')|||Thank you for providing a walk around.
The purpose to use parameter query is to avoid SQL Injection security hole. By exec a sql statement will run into this problem.

how to use parameter in rs?

the database hass a store proc with 3 parameters,
eg.create proc stp_test @.Start varchar(1024),@.End varchar(1024),@.Type
varchar(1024) as......
in the reporting project, it has 3 parameters StartA,EndA,TypeA exactly
like those above.
how to call the store proc in the reporting project?
exec stp_test @.Start=@.StartA,@.End=@.EndA,@.Type=@.TypeA ?
but it does not work,a "must declare @.StartA first" message appears
when previewing.hi,you shuld write in the query string just "stp_test ",then click on Run or
Refresh and the VS will update automaticly the parameters.
"Spirit" wrote:
> the database hass a store proc with 3 parameters,
> eg.create proc stp_test @.Start varchar(1024),@.End varchar(1024),@.Type
> varchar(1024) as......
> in the reporting project, it has 3 parameters StartA,EndA,TypeA exactly
> like those above.
> how to call the store proc in the reporting project?
> exec stp_test @.Start=@.StartA,@.End=@.EndA,@.Type=@.TypeA ?
> but it does not work,a "must declare @.StartA first" message appears
> when previewing.
>|||The above syntax works when the command type is set to
'StoredProcedure', if the command type is set to 'Text' the syntax
would be:
Exec stp_test @.Start, @.End, @.Type
This is also the syntax that must be used when you are using the Report
Wizard and it is asking for the Query String.|||thanks ,it works well.

Monday, March 12, 2012

how to use non-basic ascii chars in stored proc paramter

hi all,

I have a stored procedure with a input parameter ( xml block).

sp: spGetAddr @.xmlText

the style of parameter @.xmlText looks like

<Param RestricBy="UserName IN ('Mayá', 'Bob')"/>

If I use non-basic ASCII character, just like 'á' in the parameter, the execution fails and I get 'The error description is 'An invalid character was found in text content.''

But this kind of special characters should be allowed in the name column of the database table.

If I use the htlm code '&#xE1" to replace 'á' in the parameter, then the execution of the stored procedure is fine. but how can I change all of the possible sepcial characters?

If somebody knows how to handle this issue, please help me. I'm pre-appreciated for all the idea and suggestion!

Thanks,

Jone

When you pass the parameter to the stored procedure, make sure to use an nvarchar string. For example:

N'<Param RestricBy="UserName IN ('Mayá', 'Bob')"/>'

Regards,

Galex Yen

how to use non-basic AscII character in Stored procedure parameter

hi all,

I have a stored procedure with a input parameter ( xml block).

sp: spGetAddr @.xmlText

the style of parameter @.xmlText looks like

<Param RestricBy="UserName IN ('Mayá', 'Bob')"/>

If I use non-basic ASCII character, just like 'á' in the parameter, the execution fails and I get 'The error description is 'An invalid character was found in text content.''

But this kind of special characters should be allowed in the name column of the database table.

If I use the htlm code '&#xE1" to replace 'á' in the parameter, then the execution of the stored procedure is fine. but how can I change all of the possible sepcial characters?

If somebody knows how to handle this issue, please help me. I'm pre-appreciated for all the idea and suggestion!

Thanks,

Jone

What happens when you preface the string with the unicode identifier [ N ]?

<Param RestricBy="UserName IN (N'Mayá', 'Bob')"/>

|||

Thanks for your reply.

after preface 'N', I still got the same error.

Any idea?

Thanks,

Jone

|||

Perhaps this will prove useful for you:

http://blogs.msdn.com/mrys/archive/2005/09/06/461682.aspx

Friday, March 9, 2012

how to use GetReportParameters for a parameter with dependencies?

try to develop a customized report with personal UI.

can use GetReportParameters to get all parameters. but can not find a way to get the paramter with dependencies.

there is a perference from http://www.odetocode.com/Articles/123.aspx. I made my own code, but it never works.

any helps? thanks.

--

Dim vs() As ParameterValue = Nothing

vs(0) = New ParameterValue

vs(0).Name = pName ' dependency' name

vs(0).Value = pValue ' dependency' value

Dim ps() As ReportParameter = rs.GetReportParameters(report, Nothing, True, vs, Nothing)

When calling GetParameters you want to pass in the parameter values you have. If a dependency is satisfied by that set then the return value should have the values for the dependent parameter populated.

how to use GetReportParameters for a parameter with dependencies?

try to develop a customized report with personal UI.

can use GetReportParameters to get all parameters. but can not find a way to get the paramter with dependencies.

there is a perference from http://www.odetocode.com/Articles/123.aspx. I made my own code, but it never works.

any helps? thanks.

--

Dim vs() As ParameterValue = Nothing

vs(0) = New ParameterValue

vs(0).Name = pName ' dependency' name

vs(0).Value = pValue ' dependency' value

Dim ps() As ReportParameter = rs.GetReportParameters(report, Nothing, True, vs, Nothing)

When calling GetParameters you want to pass in the parameter values you have. If a dependency is satisfied by that set then the return value should have the values for the dependent parameter populated.

How to use fields value in code functions

Hello,
I wrote a function in vb.net and i Sent her parameter.
The function is used in a table cell.
I want the function to use a field value,
I tried :
Fileds!myFilesName.Value

But it didn't work.
Can I do this kind of thing?

Thanks.

Are you trying to write or read from a table cell? Or is it from a control in the table cell?

|||

Hi TaTworth.

I'm trying to read the value from the current row in the dataset and write it to the table cell.

I'll will try to explain again:
I have a table in my report.
in one of the cells I have a filed. something like:

=Fields!FieldName.Value

Now, Let say I want to add him the value "2". I will use:

=Fields!FieldName.Value + 2

Now, let say that I want to call a function that will add him the
value "2" and return the result.

I can use the following call:

=Code.AddTwoFunction(Fields!FieldName.Value)

And in my code I will get the Filed value as parameter and add him the
2.

What I wanted to know is if I can call the function with out the
parameter and tell her to automaticlly get the value of the field from
the row she was called?

The reason I need this is that I have a function that need to get 5
fileds and when I call it it looks some thing like:

=Code.AddTwoFunction(Fields!FieldName.Value,Fields!
FieldName2.Value,Fields!FieldName3.Value,Fields!
FieldName4.Value,Fields!FieldName5.Value)

What I would like to do is to call the function from the cell like =Code.AddTwoFunc()

and inside the function use something like:

dim str = Fields!FieldName.Value + 2;

The problem is that it doesn't recognize the"Fields!FieldName.Value"

Hope I explain my self better

|||

Shalom Shabbat AspNetO

You can go two ways - one way is to modify the dataset prior to binding to a datagrid, the other is to set up a suitable table structure to contain all your data cells, giving each cell its own runat="server" and its own id value, you can then read and write from each cell. When reading use a NullToString functions as in http://forums.asp.net/p/1091080/1635818.aspx#1635818 and then cast the string to an integer.

Thus if the contents of tddA1, tddA2 are to be added to give tddA3, then

string sA1 = NullToString(tddA1.InnnerText);
string sA2 = NullToString(tddA2.InnnerText);
int iA1 = System.Convert.ToInt32(sA1);
int iA2 = System.Convert.ToInt32(sA2);
tddA3.InnerText = (iA1 + iA2).ToString();