Avatar of sydneyguy
sydneyguy
Flag for Australia asked on

c# sql server retuning an extr \ when a " is found

have a data base sql server that i am running the records from , and one of the fields that is returned will hold the data of  .... <iabc-type="ppub">  .....  but when its returned it comes back as "<iabc-type=\"ppub\">"  with the extra \ in the code which it will not find in the text file that it is looking for, because i am looking for   <iabc-type="ppub">   instead of
 "<iabc-type=\"ppub\">"  any ideas on what i can put into the data base field to stop these \ from being returned every time it hits a " mark
.NET ProgrammingMicrosoft SQL ServerC#

Avatar of undefined
Last Comment
sydneyguy

8/22/2022 - Mon
Imran Javed Zia

Hi,
In c# back slash \ is escape sequence speifier. and double qoutation " is special character too.
if you need \ then specify \\ twice or use @ to make string to be used as it is.

thereofr check that your data in sql server has the related data. please also specify sql server verion and also add it in the zone
Thanks
sydneyguy

ASKER
not sure if its a sql server problem or a c# return problem
in the field in the sql server 2005 table i have the text
<iabc-type="nlm-ta">    
but after i read in the field by a  dt = readrec("select * from tblSearchTerms");
the returned string is "<iabc-type=\"nlm-ta\">    
and i need to get rid of the \ in the returned string, so either i need to take it out in the field or the returned string
also using studios 2005
sydneyguy

ASKER
you cannot use string replace because it does not like the \ in the function
sqlstringtemp = sqlstringstart.Replace("\", "");
wil not comnpile
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Imran Javed Zia

then change your data in sql server as
<iabc-type=\"nlm-ta\">

or use following in c#
sqlstringtemp = sqlstringstart.Replace("\"", "\\\"");
sydneyguy

ASKER
sqlstringtemp = sqlstringstart.Replace("\"", "\\\"");
line changes to which is not workable
<iabc-type=\\\"nlm-ta\\\">

<iabc-type=\"nlm-ta\">   in the data base returns
<iabc-type=\\\"nlm-ta\\\">
which also is no good as i need to get rid of the \ not increase the numbers for the string
ASKER CERTIFIED SOLUTION
Imran Javed Zia

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Nasir Razzaq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
sydneyguy

ASKER
yes you were right when i run and not worry about them the code woks just fine bit of a furphy
thanks for the imput
posted the points for how much input you put into the question
thanks
garry
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.