Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 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 April 3rd, 2008, 09:19 AM
Registered User
 
Join Date: Apr 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default apostrophe ' problem in comparison

tablink = "t20002001"
            Dim adp As New OleDb.OleDbDataAdapter("select * from " & tablink & " WHERE name = '" & tbname.Text & "' and fhname = '" & tbfhname.Text & "'", con)

i am using above code line. my database is in hindi,so in hindi a character is translated as apostrophe in english keyboard. whenever i compare such word which contains apostrophe in tbname.text text box, it creates syntax error. how to solve this problem.



ramni
 
Old April 3rd, 2008, 09:38 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

Replace ' with ''

Your database should handle that.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old April 3rd, 2008, 11:19 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Why are you using single quotes in variable names? Variable names are part of the program code, and need not be linguistically accurate.

Though it might read better, changing the variable name to jai_jhkkl or jaíjhkkl or jaí_jhkkl would permit the program to run, and should be clear enough so as to understand the code for maintenance later.

You also can use comments to make code clearer when you have to corrupt a legitimate word so as to use it as a variable name:
Code:
    tbname.text = "'" & jaí_jhkkl & "'" ' <———<<< jaí_jhkkl is actually jai'jhkkl.
(Actually, what you posted as your code doesn't make sense. As far as I'm aware, .NET does not recognize ' as text delimiter, and databses do not recognize designations like tbname.text...)
 
Old April 3rd, 2008, 11:27 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

You are quite right Brian, using an ' in a variable name declaration will cause a compiler error. While the code presented isn't syntactilly correct I inferred that the syntax was probably irrelevant since this individual probably replaced the actual variable name with jai'jhkkl to demonstrate their point. Of course this is just an assumption and you know what that can lead to!

As always your bring up some very good points as well.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old April 3rd, 2008, 11:21 PM
Registered User
 
Join Date: Apr 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for helping me. i must clear my query first my coding is as follows:

 Dim adp5 As New OleDb.OleDbDataAdapter("select * from " & tablink & " WHERE name = '" & tbname.Text & "' and fhname = '" & tbfhname.Text & "' ", con)

here in hindi database column name there is a value like "kjkjiuo'jkj"
this single code makes syntax error during execution of the program.
now my query is clear and any suggestion regarding it is most welcome.

ramni





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:when test - comparison problem pelicanPaul XSLT 1 June 29th, 2007 04:45 AM
Date comparison problem mat41 Javascript 3 August 30th, 2006 09:22 PM
Regular Expression Apostrophe Problem in .NET kwilliams General .NET 1 February 17th, 2006 04:10 PM
Access Form problem, date comparison jackson_jl VB Databases Basics 0 March 9th, 2005 02:13 PM
Please Help Xslt comparison problem helensobrien XSLT 4 February 21st, 2005 01:37 PM





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