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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Single Quote Problem

Author  Topic 

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-03-25 : 01:52:23
Hi All,

In our application we have remark field, where user can input any free text regarding that pariticular transaction. So somtimes he also input single quotes ("'"), but for inserting there we are inserting from that textbox to the database we are using ADO Method (Calling Update Method of RecordSet) so it doesnt give any error of single quotes.

But on some transaction we are inserting the value into some other tables, so while updating that table its gives error of single quotes.

What i did Replaced all the single quotes with the double quotes in the remarks column and that trasaction worked fine for me.

But now when the user goes to that screen instead of displaying single quotes it shows double single quotes for eg instead of showing "that's" it showing "that''s".

Please let me know what will be best solution for this kind of problem.



Sucess Comes to those who Believe in Beauty of their Dream..

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-25 : 08:31:06
Just some ideas:

1 way --> Replace all single quotes with 2 single quotes when inserting and updating
Select --> do as usual.
(U may need to update all existing data with Replace function, Replacing double
quotes with single quote)

2nd way --> Leave current data entry as it is
When Displaying data, replace double quote with a single quote
(This way I think less professional)
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-03-25 : 10:05:40
quote:

1 way --> Replace all single quotes with 2 single quotes when inserting and updating
Select --> do as usual.
(U may need to update all existing data with Replace function, Replacing double
quotes with single quote)



I didnt understand.. means i should replace all the data with the single to double single quotes.. ??
Actaully i did the same.. but when selecting the records and dispalying on the screen it displays double single quotes.. which is not proper... :(

Any Ideas??

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-03-25 : 12:14:22
replace ' with ´

that's what we did. noone complained.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-25 : 13:01:55
Create table #MyT (F1 varchar(50))
Go
Insert into #myT values('abc')
Insert into #myT values('pq''r')
Insert into #myT values('xy''''z')

Select * from #myT
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-03-26 : 01:20:30
quote:

replace ' with ´
that's what we did. noone complained.



Thanks.. Good Idea..

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-27 : 01:56:41
If you replace single quote by double single quotes when inserting, then they will actaully be stored as single single quote and wont display as you stated

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -