Replacing Single Quotes when formatting SQL

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 6
September 01, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement
This is one of those things you will pick up if you use formatted SQL when submitting data to the database via an ASP page.  If you using ADO you won't have this problem but.  I like using formatted SQL cause its native to the any database.  If its native it will run faster.  Any performance gains I can get I'll do it.  I haven't did any performance testing between using ADO or formatted SQL but its just my opinion.  If you want to view live demos how-to Insert and Update Records using Formatted SQL statements.

Here is a piece of code to get rid of this problem, as your building your SQL string just use the replace statement

strSQL = strSQL & "'" & replace(request("Field1"), "'", "''") & "' as text1"

This is a typed out version so there is no confusion to what the string above should look like. 

strSQL = strSQL & Double Quote Single Quote Double Quote & replace(request(double quote FieldName1 Double Quote) comma Double Quote Single Quote Double Quote) & Double Quote Single quote as text comma Double Quote

blog comments powered by Disqus
DATABASE CODE ARTICLES

- Deployment of the MobiLink Synchronization M...
- MobiLink Synchronization Wizard in SQL Anywh...
- Finding Matching Records in Data Access Pages
- Using the AccessDataSource Control in VS 2005
- A Closer Look at ADO.NET: The Command Object
- A Closer Look at ADO.NET: The Connection Obj...
- Using ADO to Communicate with the Database, ...
- Code Snippets: Counting Records
- Constraints In Microsoft SQL Server 2000
- Multilingual entries into a DB and to be dis...
- Two combos, one textbox example
- ADO Recordset Paging
- SQL Server Database Creator - .NET Version
- Getting A List of Tables From SQL Server
- Discussion & Listserv Module by Mike Eck...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials