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.
Printable View
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.
Can you substitute two apostrophes instead?
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.
I think what dglienna means is that you do something like this: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.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, "'", "''") & "'"
will it work if i search a record with no apostrophe?
Yes. No problem. :thumb:
Thanks. I was suggesting the same thing. You explained it well.
ei guys thanx for the time. i really appreciate it. GOD BLESS :thumb: