Link to home
Create AccountLog in
.NET Programming

.NET Programming

--

Questions

--

Followers

Top Experts

Avatar of Vignesh Kumar
Vignesh Kumar

Remove backslash from string c#
Hi,

I am trying to add a value to a queryparameters for reporting services programmatically.

 
 List<QueryParameter> lst = new List<QueryParameter>();
 QueryParameter qp = new QueryParameter();
 qp.Name = "@UserID";
 qp.Value = "[@UserID]";
 lst.Add(qp);

Open in new window

The values are getting inserted, but with \ character and is it because of @. My QueryParameter value should be like [@UserID] and instead it is displayed as \[@UserID\].

User generated image
How can I remove the \ from the value and the \ doesn't show when I debug.

Really appreciate any suggestions.

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Gustav BrockGustav Brock๐Ÿ‡ฉ๐Ÿ‡ฐ

Wouldn't this do:

ย  ย  qp.Value = @"[@UserID]";

/gustav

Avatar of Pawan KumarPawan Kumar๐Ÿ‡ฎ๐Ÿ‡ณ

Try..

YourParameter = YourParameter.Replace("\", "");

Avatar of Vignesh KumarVignesh Kumar

ASKER

@Gustav Brock - I have tried this and it doesn't remove the \ from the value.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Pawan KumarPawan Kumar๐Ÿ‡ฎ๐Ÿ‡ณ

Hi Vignesh,
What about mine?

Regards,
Pawan

@Pawan - The \ character is not visible in code and even if I debug I'm not able to find it. \ value is getting created in UI mentioned in the image in post. Also I cannot use replace method for this queryparameter object.

Avatar of Pawan KumarPawan Kumar๐Ÿ‡ฎ๐Ÿ‡ณ

Use double \\ and check . Where are you trying this , in SSRS, SQL ?

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


@Pawan - In that case it creates double slash.

Avatar of Pawan KumarPawan Kumar๐Ÿ‡ฎ๐Ÿ‡ณ

Where are you trying this , in SSRS, SQL ?

@Pawan - I'm trying to add parameter value to SSRS through c# using rdlobjectmodel API.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Pawan KumarPawan Kumar๐Ÿ‡ฎ๐Ÿ‡ณ

Please post c# code

ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der WerkenDaniel Van Der Werken๐Ÿ‡บ๐Ÿ‡ธ

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of Pawan KumarPawan Kumar๐Ÿ‡ฎ๐Ÿ‡ณ

Hi Author,

Any luck with this?
.NET Programming

.NET Programming

--

Questions

--

Followers

Top Experts

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.