Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem with '&' character, not able to update ID

Author  Topic 

teena
Starting Member

1 Post

Posted - 2011-05-12 : 12:55:21
Hi all,

In my code, i have a ProductID which contains '&' character like "pen&pencil".I tried to update this as "pen&paper" from front end into database.But,database doesn't accept this changes..it remains as "pen&pencil"..Actually,I have created stored procedure for "update" and calling that in my code behind file.From front-end form , i'm entering new value and trying to update it. My code for update is as below -



@ProductID char(15),

@NewProductID char(15) = NULL,

Update ProductTable SET ProductID = @NewProductID WHERE ProductID = @ProductID

Please help me out.

Thanks in advance,



Teena

teena

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-12 : 13:11:30
There's nothing wrong with your syntax, your table design...
DECLARE @Table TABLE (Productid char(15))

INSERT INTO @Table select 'pen&pencil'

select * from @table
DECLARE
@ProductID char(15),
@NewProductID char(15)

SET @NewProductID = 'pen&paper'
SET @ProductID = 'pen&pencil'

UPDATE @Table
SET Productid= @NewProductID
WHERE Productid = @ProductID


select * from @table

Maybe one of your parameters isn't being passed thru as expected?

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-05-12 : 13:50:34
Any chance the "&" is encoded as "&" because of some xml encoding?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -