• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Problem with & when using a web service

I am using third party webservice to create records.

I read in from database this title

   "Customers & Records"

    However the webservice writes to database as

    "Customers & invoices"

notice it adds      "&"     instead of &

What is the best way around this?  I want it to write "&" as oppose to "&"


In my code I have  

customercategory thiscategory = new customercategory();
thiscategory.title = /////read in tite from database



0
mugsey
Asked:
mugsey
  • 2
  • 2
1 Solution
 
VikramMullickCommented:
try using && instead of &
0
 
mugseyAuthor Commented:
Thanks but I cannot modify the database table I am reading from
0
 
VikramMullickCommented:
I guess you might be using dataset/datatable for fetching data .
Then try to replace/append the & symbol and then send it to webservice.
0
 
mugseyAuthor Commented:
Yes I have been doing that with string.replace  but I need the "&" to be preserved
0
 
ProdigeCommented:
It appears the problem is not so much with the fetching. The problem lies in how the web service communicates with the database. Posting via the webservice will adjust the input data to be a valid soap message and converts your & to the html / xml equivalent of & but it does not appear to be converting it back to an & when it hits the db.

If you have no access to the see what the web service is doing then you either have to search and replace the "&" with "and" or try using the url safe version which is "%26", last resort would be to try and use the hex version "#26"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now