Special Character Conversion

L

Lucky

Hi Guys!!!
i'm newbie to asp.net 2.0. i've got a problem. i've a textfield on my
webpage and if i insert " can't " or " test - test " value into it and
post it back the " ' " and " - " get converted into the blocks and i
got a procedure to store them into the SQL server 2000 database where
the field has varchar type. while it gets stores, it gets converted
into the " ? ". so it reads like " can?t " and " test?test ". i dont
know where is the conversion occured.

i've check almost all the possiblities of datatype missmatch in the
procedure and the data column in the database but nothing seems
working.

i've same problem with the NVARCHAR data type field also.

please help me out to locate this problem. i'm not able to understand
what's wrong with this things.

thanks in advance.

Lucky
 
J

Jason Hales

When you execute your stored proc to store the values, are you using
the SqlCommand.Parameters collection to set stored proc parameters or
are you executing a SqlCommand by setting the CommandText to something
like "exec spUpdateValue 'can't' ".

Using the Parameter's collection ADO.net will properly esacape
characters like '. The above exec line won't run because you must
prefix a single quote with another single quote as "exec spUpdateValue
'can''t' "

I've never seen a "-" being converted like that. ADO might think
you're trying to refer to a column called "test".
 
L

Lucky

i\m not sure about ado.net behaviour. i\m using SqlParamaters to pass
the values so i dont think it should manipulate the values.

may be when i\m posting back the values to the server that time they
are getting replaced coz i checked for the character and it has
recognized " ' " as control character.


still wondering where it the fault
 
J

Jason Hales

Can you post some of the ASP.NET code that calls the stored proc and
and the stored proc definition itself?
 
J

Joerg Jooss

Thus wrote Lucky,
Hi Guys!!!
i'm newbie to asp.net 2.0. i've got a problem. i've a textfield on
my
webpage and if i insert " can't " or " test - test " value into it and
post it back the " ' " and " - " get converted into the blocks and i
got a procedure to store them into the SQL server 2000 database where
the field has varchar type. while it gets stores, it gets converted
into the " ? ". so it reads like " can?t " and " test?test ". i dont
know where is the conversion occured.

Are these really the basic apostrophe and hyphen/minus, or some Unicode characters
like ’ or —? The latter cannot be stuffed in a varchar.
i've check almost all the possiblities of datatype missmatch in the
procedure and the data column in the database but nothing seems
working.

i've same problem with the NVARCHAR data type field also.

please help me out to locate this problem. i'm not able to understand
what's wrong with this things.

You may also lose them due to the wrong request encoding. Are you posting
from an ASP.NET page or some other page (ASP, PHP, plain HTML)? What requestEncoding
have you set in web.config?

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top