0 Members
0 added today
0 Resources

All Devdex   All Gurus  

Problem inserting text in Sql Server
Author: Toshit Bhardwaj
Rating:
Visits: 3873

Discuss in Newsgroups

You might have experienced a problem in inserting a text in sql server through web page.

Problem occurs when you try to insert something like this " hello world's ".

Because you are trying to insert ( ' ) n the string, because sql server interpret it as a termination of string.

Try to insert "hello's world's" , you won't be having any problem.

To solve this problem, we can use this function , which creats one more ( ' ) at the end of the string and makes it according to sql server.

function padQuotes( instring )

Dim bodybuild
Dim bodystring
Dim Length
Dim i

bodybuild = ""
bodystring = instring
Length = Len(bodystring)
For i = 1 to length
bodybuild = bodybuild & Mid(bodystring, i, 1)
If Mid(bodystring, i, 1) = Chr(39) Then
bodybuild = bodybuild & Mid(bodystring, i, 1)
End If
Next
bodystring = bodybuild
padQuotes = bodystring
End function


Visit my guru profile

Visitor Comments

John Armagh I have found the following syntax useful:- Dim ...
Anonymous User all you have to do is add an additional single quo...
Anonymous User all you have to do is add an additional single quo...
Anonymous User This is a good article and solves many problems.I ...

 

Rate this Code Sample






	
	
	



ASP.NET Chart Control.
Charts from your Database.
Live Demo & FREE Trial!

ASP ArticlesThis category has been added to your weekly newsletter
ASP Web Sites
ADSI & WSH BooksThis category has been added to your weekly newsletter
FREE ComponentsThis category has been added to your weekly newsletter
ASP EventsThis category has been added to your weekly newsletter
ASP HeadlinesThis category has been added to your weekly newsletter

CSharp ArticlesThis category has been added to your weekly newsletter
C# Web SitesThis category has been added to your weekly newsletter

SQL ArticlesThis category has been added to your weekly newsletter
SQL Events
SQL HeadlinesThis category has been added to your weekly newsletter
SQL Jobs

Jobs in CaliforniaThis category has been added to your weekly newsletter

XML ArticlesThis category has been added to your weekly newsletter
XML BooksThis category has been added to your weekly newsletter
XML Web Sites
XML Tutorials

free asp host

"Alex Homer"This search has been added to your weekly newsletter

Edit My Favorites Edit Profile & Favorites

 




Developersdex Home | ASP | C# | SQL | VB | XML | Gurus
Add Your Link | Add Your Code | FAQ | Advertise | Link To Us | Contact Us |
Copyright © 2010 Developersdex™. All rights reserved.