Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2006, 01:22 AM
Authorized User
 
Join Date: Jan 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Username is not accepted in to the database

hai everyone,

       while i am adding a username with single quote "'" from a Form in asp.net page to the database it fails. can anyone suggest the best possible way to insert it in to the databse and get it from database to the asp.net page.

thanks in advance
Madhu

__________________
Regards,
P.Madhusudhana Rao
 
Old March 17th, 2006, 08:09 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

These characters will cause your SQL statement to crash: ' and , so call the replace function.

Dim strName as string = "Kevin O'Grady"
strName = strName.Replace("'","''")
strName = strName.Replace(",", "',") 'With the above string this does nothing
INSERT INTO Logins(Name) VALUES('" & strName &"')

"The one language all programmers understand is profanity."
 
Old March 17th, 2006, 09:05 AM
Authorized User
 
Join Date: Jan 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hai dparsons,

    i am very thankfull to u as u have given the right and good sugesstion which had worked.

Madhu

 
Old March 19th, 2006, 12:19 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Glad I could help.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass UserName to Database sterreyl ASP.NET 2.0 Basics 0 March 11th, 2007 11:26 AM
Global variable passed from s/proc not accepted ssharrock SQL Server DTS 1 February 24th, 2005 12:28 AM
Username Changes Ben Horne Forum and Wrox.com Feedback 2 March 12th, 2004 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.