Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 September 10th, 2003, 11:16 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default hi, text box ques...

hi, i use a text box to let user type in something and then insert the text to database, but i found that if the user type ' in the text box, example " he's ", it will show the error when inserting to database.

it cause the insert string to have extra '..... i wonder if there is anyway to solve, or user is not allowed to use ' in text box... thanks

best regards
Life's Ng

 
Old September 11th, 2003, 12:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

can u send ur CommandString?

Always:),
Hovik Melkomian.
 
Old September 11th, 2003, 01:30 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

DIM Mysql as String= "INSERT INTO CFBReport (InfestLevel, AddRemarks, DbShow) VALUES ( '"& DdlLvl.SelectedItem.Text &"','"& tbRemark.Text &"' , '"& dbtxt &"')"
                 dim objCmd as New OleDbCommand (Mysql, Conn)
                 Conn.Open()
                 objCmd.ExecuteNonQuery()
                 Conn.Close()

it'll show me this error
Exception Details: System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression ''hi's' , 'OnShow')'.



 
Old September 11th, 2003, 01:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

first I think the way u r going is not good! & let me to suggest u something! NEVER use ur Command in that way! set Parameters for ur Command & then set the parameters. This way have better performance & Clear code. Anyway make a commandText with some parametrs u need & then set them. u can also use SP & its better.
HTH.

Always:),
Hovik Melkomian.
 
Old September 11th, 2003, 02:19 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

now i c... thanks Melvik!


 
Old September 11th, 2003, 08:38 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

hi Melvik, im using this command to solve this problem

tbTextBox.Text= tbTextBox.Text.Replace("'" , "''")

it works nicely!

best regards
Life's Ng

 
Old September 11th, 2003, 08:54 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

sorry, its (" ' " , " ' ' ")

 
Old September 11th, 2003, 08:56 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

hi melvik, can u send me ur email address? there is something i wish to ask personally. thanks.

best regards
life's Ng

 
Old September 13th, 2003, 02:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

http://p2p.wrox.com/pop_profile.asp?...isplay&id=1047

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Extract text from text file & put in dropdown box tsukey Beginning PHP 5 July 20th, 2004 09:49 PM
Rich Text Box vs Text Box snowy0 VB.NET 2002/2003 Basics 1 February 17th, 2004 02:11 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





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