|
-
Apr 4th, 2005, 12:40 AM
#1
Thread Starter
Hyperactive Member
error in search query [RESOLVED]
i have data in different tables, then i want to query them by calling their product name, everything seem going well until i have a data with an apostrophe in it's name.
Last edited by kulitag; Apr 4th, 2005 at 01:27 AM.
Reason: RESOLVED
-
Apr 4th, 2005, 12:41 AM
#2
Re: error in search query
Can you substitute two apostrophes instead?
-
Apr 4th, 2005, 12:43 AM
#3
Thread Starter
Hyperactive Member
Re: error in search query
no can do sir coz the system is for the use of other user. the just encode the products. it's for my inventory system.
-
Apr 4th, 2005, 01:08 AM
#4
Re: error in search query
I think what dglienna means is that you do something like this:
VB Code:
Dim sql As String
Dim PName As String
PName = "Woka'[color=black]s Widget"[/color]
sql = "Select [blah] From [Inventory] "
sql = sql & "Where [Product Name] = '" & Replace$(PName, "'", "''") & "'"
The Replace$() function is searching the product name for a single apostrophe " ' ", and replacing it with two apostrophes, " ' ' " (I've expanded these to make it easier to see what's going on). Your query should then work OK with names containing apostrophes.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Apr 4th, 2005, 01:13 AM
#5
Thread Starter
Hyperactive Member
Re: error in search query
will it work if i search a record with no apostrophe?
-
Apr 4th, 2005, 01:20 AM
#6
Re: error in search query
Yes. No problem.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Apr 4th, 2005, 01:22 AM
#7
Re: error in search query
Thanks. I was suggesting the same thing. You explained it well.
-
Apr 4th, 2005, 01:26 AM
#8
Thread Starter
Hyperactive Member
Re: error in search query[resolved]
ei guys thanx for the time. i really appreciate it. GOD BLESS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|