.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Error Converting Regex to C# - Unrecognized escape sequence

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :Windows Application

Hi, I just converted a Regex for stripping HTML tags from VB to C#, but now whenever I try to run it I get the error " Unrecognized escape sequence". In VS 2010 it highlights every / character, but I don't know how to build the regex without those characters.

C# Converted from VB

string strDesc = description.ToString();
        System.Text.StringBuilder striptags = new System.Text.StringBuilder();
        string htmltags = striptags.ToString();
        Regex tagstrip = new Regex(htmltags);
        strDesc = tagstrip.Replace(htmltags, String.Empty);


Original VB Code:

 Dim regularexp As New System.Text.St

View Complete Post

More Related Resource Links

unrecognized escape sequence in SQL connection string



In my program, I want to make database connectivity, but when i write a connection string, complier says that it is unrecognized escape sequence(which is bolded in the following string), the string is :

Data Source=HIMANSHU\SQLEXPRESS;Initial Catalog=Himanshu;Integrated Security=True

How can I resolve my problem?


All my server-controls became unrecognized!!! like there's compilation error or web.config missing!



please help - the problem is in post subject.

I have lots of warnings with following text:

"Warning 10 Element 'HyperLink' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing. C:\Users\Pavel\Documents\Visual Studio 2010\WebSites\BioWebSite\ToScientist.aspx 26 18 C:\...\BioWebSite\" 

But web.confg is there! And there's no compilation error!

Site builds just fine. And If I upload it to my hoster - it works!


But with all these errors I cant add controls to pages - VS2010 adds hyperlink without ID, and intelisens stoped to work.

Strange, but in my other project (web-application) I have no such difficuty.

Error converting data type varchar to numeric.


I create a form to record data using ASP.NET and SQL database...
when i run the project show error "Error converting data type varchar to numeric"

what's the problem actually.i try to change in datatype in database..
but still showing error...


Split string using Regex with escape sequences

What is the regex to split a string using the delimiter ';', but not split on '\;' ? Backslash would be my escape character in my split string, so finding '\;' would not split, but '\\;' would split. For example I want a regex that would split the following:     "aaa;bb;cccc\;dd\;eee\\;ff\\;ggg\\\;hhh" into the following string array:     aaa     bb     ccc\;dd\;eee\\     ff\\     ggg\\\;hhh   Thanks!   -Sylvain

Error in SharePoint Designer when converting to XSL

While using SharePoint Designer, I attempt to convert a web part "list view"  to XSL and i get the error:  "The server returned a non-specific error when trying to get data from the data source.  Check the format and content of your query and try again.  If the problem persists, contact the server administrator."  Was able to convert this same web part a week ago, and now I am getting this error.  I have restarted all of the servers and still receive this error.  The only thing I can think of is that there might be an issue with having too much data in the list.  Any ideas?

Error converting data type nvarchar to numeric.

i create a form using form view tools in asp.net..when i click insert command it shows error..this is code which i use for InsertCommand:<asp:SqlDataSource ID="SqlDataSourceFormView" runat="server"         ConnectionString="<%$ ConnectionStrings:AED_PanasonicConnectionString2 %>"         SelectCommand="SELECT * FROM [Debtor]"        InsertCommand="INSERT INTO Debtor (CompanyName, Desc2, RegisterNo, Address1, Address2, Address3, Address4, PostCode)VALUES (@CompanyName, @Desc2, @RegisterNo, @Address1, @Address2, @Address3, @Address4, @PostCode)">        </asp:SqlDataSource>Error:-Error converting data type nvarchar to numeric.where i have to make changes?

Arithmetic overflow error converting expression to data type smallint

Can anyone tell me what exactly this means? Arithmetic overflow error converting expression to data type smallint. 

error converting nvarchar to int

i have two multivalue paramaters in a report and when I try to select more that one value for the results then i get this error when rendering the rpt both paramaters are int in the value field but I am displaying the label in the screen of the selection and passing the value as into the sproc.   it works with only one value

Error converting data type nvarchar to datetime.

hi all, I simply explain my application.plz try to understand. In my applicationi want to generate one complaint id.one customer may give two or more complaints at a time.suppose,he give two or more pnr numbers and their status and prioirty may differs.for this complaint i need to generate one common complaint id.how it is possible..?with some constant rows. am getting error in Class File near CLUser_Logged_DTClass File using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; /// <summary> /// Summary description for BalComplaints /// </summary> public class BalComplaints { public BalComplaints() { // // TODO: Add constructor logic here // } int SNo, Complaint_Type_ID, Caller_Type_ID, No_of_Articles, Article_ID, CLPriority_ID, Status_ID, Origin_ID, Destination_ID; public int SNo1 { get { return SNo; } set { SNo = value; } } public int Caller_Type_ID1 { get { return Caller_Type_ID; } set { Caller_Type_ID = value; } } public int Destination_ID1 { get { return Destination_ID; } set { Destination

Error converting data type varchar to numeric



I am trying to execute below query.



CAST('123,456,789.00' AS DECIMAL(11,2))

SQL error: Conversion failed when converting date and/or time from character string.

I hope someone can advise on the issue I'm having.

This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '

By adding in this condition, I now get the following error:

Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.

I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.

(The CONVERT function is being used in setup for a PIVOT SQL which needs  VARCHAR for column headers)

Thanks in advance for your help, 

declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''

ORA-00255: error archiving log of thread , sequence #



I have the above error when filling a dataset from an oledbconnection into a dataset


 I have had a shorter version of the query working fine


the query works fine in the oracle client


any ideas


thanks in advance

Error converting data type nvarchar to numeric in Store Procedure execution



When I execute a Store Procedure via 'EXEC sp_XXX @p1, @p2' I'm getting this error 'Error converting data type nvarchar to numeric'.

After diggin into the TSQL code I have found that there's a field (type: nvarchar(200)) breaking the execution and resulting on the error.

If I query the table and the specified field with the same parameters as the Store Procedure the results are ok! If I execute the same code as the Store Procedure with the same parameters values the results are ok. The error only happens when executing the Store Procedure.

Any idea ?

Thanks in advance,

Gustavo Brian


If I cast the field to a smaller size value, as nvarchar(80), it works, but of course with data truncation.


"IN" operator and error converting data type varchar to numeric



I hope someone can help me figure this out please...

I have this query that returns some student data - specifically the student's names, and some classes they're enroled in. What I'm trying to do is return multiple rows using the LIKE operator.

However when I run it and plug in the parameters I get the errror - "Error converting data type varchar to numeric". This error doesn't occur when there is only ONE studentId. Only when there are multiple studentIds. I know it's to do with the string of studentIds being passed, but I'm not sure how to fix it?

Should I be using varchar as the datatype to pass the studentIds? Or do I need to cast this as something else?

Any ideas, much appreciated.



	@StudentIds varchar(8000),
	@ProfileId numeric,
	@Fname varchar(50) OUTPUT,
	@Lname varchar(50) OUTPUT,
	@ClassName varchar (100) OUTPUT,
	@ClassName2 varchar (100) OUTPUT,
	@ClassName3 varchar (100) OUTPUT,
	@ClassName4 varchar (100) OUTPUT,
	@Class numeric OUTPUT,
	@Class2 numeric OUTPUT,
	@Class3 numeric OUTPUT,
	@Class4 numeric OUTPUT


@Fname = Fname, @Lname = Lname, @ClassName = C.ClassName, @ClassName2 = C2.ClassName, @ClassName3 = C3.ClassName, @ClassName4 = C4.ClassName,

SQL Agent Job - PowerShell step giving escape token error



I'm confused as to why I'm getting this error:

The job step contains tokens. For SQL Server 2005 Service Pack 1 or later, you must use the appropriate ESCAPE_xxx macro to update job steps containing tokens before the job can run.).  The step failed.

The job is a single Powershell script step like this:


Get-ChildItem -path "\\server\share-Logs\" -recurse -include *.log | Where-Object {($_.CreationTime -le $((Get-Date).AddDays(-35)))} | Remove-Item


This runs fine from the PS command-line but after testing this part is causing the error: $(Get-Date.AddDays(-35)) , in the Job step

This isn't TSQL or a token - so I don't understand why it doesn't just get put as-is into the PS command-line when the job runs.

Any help appreciated.


Error converting data type varchar to numeric in SQL SERVER

Hi frendz..
Demo Example is...

alter FUNCTION [dbo].[Return_Example] 
@a numeric(18,4),
@b numeric(18,4)
RETURNS numeric(18,4)
@division numeric(18,4),
@reminder numeric(18,4),
@Num2 varchar(100),
@c numeric(18,4)

set @division=floor(@a/@b)
set @reminder=@a%@b
----Here output will be a concatenated
set @Num2= cast((@division +'.'+ @reminder) as numeric(10,3)) 
set @c=cast(@Num2 as numeric(18,3))


Execute :

exec Return_Example 50 ,5

Error The tools version "3.5" is unrecognized.



I installed VS 2008 setup on my computer.

I am having Windows XP OS with SP2.

When I opened VS 2008 and clicked on Create Project , I got the following error.

"The tools version "3.5" is unrecognized."

Please tell me how to resolve this.

Thanks in advance.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend