473,657 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Apostrophe error while retrieving the record from the database

I am using a Replace function to replace single quotes with double when
submitting a text field in the database i.e. Replace (q, "'", "' ' ")
which works fine. When I retrieve the field from the database which has
apostrophe I am getting 'Object expected' error message. Is there a
way to fix this?
Thanks,
Bhavna

Jul 19 '06 #1
10 4116

Bhavna wrote:
I am using a Replace function to replace single quotes with double when
submitting a text field in the database i.e. Replace (q, "'", "' ' ")
which works fine. When I retrieve the field from the database which has
apostrophe I am getting 'Object expected' error message. Even though I am checking in the code for apostrophe. For e.g. strOutput = Replace(strOutp ut, "'", "'")
Is there a way to fix this?
Thanks,
Bhavna
Jul 19 '06 #2

Bhavna wrote:
I am using a Replace function to replace single quotes with double when
submitting a text field in the database i.e. Replace (q, "'", "' ' ")
which works fine. When I retrieve the field from the database which has
apostrophe I am getting 'Object expected' error message. Is there a
way to fix this?
Thanks,
Bhavna
When I am retrieving the records from the db I am checking for
apostrophe. For e.g. strOutput = Replace(strOutp ut, "'", "'").
Still I am getting Object expected error message

Jul 19 '06 #3
Have you tried using chr() instead?
strOutput = Replace(strOutp ut, chr(34), chr(39))
..
"Bhavna" <bh**********@h otmail.comwrote in message
news:11******** **************@ s13g2000cwa.goo glegroups.com.. .
>
Bhavna wrote:
I am using a Replace function to replace single quotes with double when
submitting a text field in the database i.e. Replace (q, "'", "' ' ")
which works fine. When I retrieve the field from the database which has
apostrophe I am getting 'Object expected' error message. Is there a
way to fix this?
Thanks,
Bhavna

When I am retrieving the records from the db I am checking for
apostrophe. For e.g. strOutput = Replace(strOutp ut, "'", "&apos;").
Still I am getting Object expected error message

Jul 19 '06 #4
One thing I don't understand anytime I am replacing anything with
apostrophe it's throwing an error. Any help is appreciated.
Thanks,
Bhavna

Jul 20 '06 #5
Bhavna wrote:
I am using a Replace function to replace single quotes with double
when submitting a text field in the database i.e.
What database? Type and version please. Never ask a database-related
question without revealing this information up front. It is almost
always relevant.
Replace (q, "'", "'
' ") which works fine. When I retrieve the field from the database
which has apostrophe I am getting 'Object expected' error message. Is
there a way to fix this?

Write a small page (a repro page) that contains the bare minimum amount
of code that shows how to reproduce the problem and post it here. Also
post instructions on how to create any database objects that are needed
to run the reproduce the problem. We should be able to run your repro
page in our environment and see the problem occurring.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 20 '06 #6
Example

dim namex
namex="Mc'Donal ds"
Select name from table where name='" & namex & "'"

the ' in Mc'Donalds terminates the value to Mc and
will generate an error because of the extra ' generated by & "'"

This way of doing recordset queries is open to SQL
injection, so do not use it, it is just an example

"Bhavna" <bh**********@h otmail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
One thing I don't understand anytime I am replacing anything with
apostrophe it's throwing an error. Any help is appreciated.
Thanks,
Bhavna

Jul 20 '06 #7
What about showing us some code ?

Also not sure but my understanding is that you change this particular
character both when storing and retrieving values ? If yes this is IMO a bad
approach as the character is not correctly stored in the DB which could be
not really convenient.

Depending on your DB the real problem is that the quote such as in 'O'Hara'
is seen as if it were the end marker of the string. Replacing by a double
quote will fix the problem 'O''hara'?
This will store O'Hara in the DB, you have the correct char in the DB and
you don't have any change to do when retrieving the value.

Another option is to use parameters instead of building SQL queries as
text...

Don't know but it lloks like that this problem could actually hide a design
problem you may want to check....

--
Patrice

"Bhavna" <bh**********@h otmail.coma écrit dans le message de news:
11************* ********@b28g20 00...legro ups.com...
One thing I don't understand anytime I am replacing anything with
apostrophe it's throwing an error. Any help is appreciated.
Thanks,
Bhavna

Jul 20 '06 #8
ple help me anyone

i am using ms access database

tqty is text fields

rsCount.open "Select Sum(TQty) as temp from tbl_style where IPomsID="&
cdbl(request("I PomsID")),con,2 ,3

when i am exeuting query it gives below error

Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
rsCount.open "Select Sum(TQty) as temp from tbl_style where IPomsID="&
cdbl(request("I PomsID")),con,2 ,3
Bhavna wrote:
I am using a Replace function to replace single quotes with double when
submitting a text field in the database i.e. Replace (q, "'", "' ' ")
which works fine. When I retrieve the field from the database which has
apostrophe I am getting 'Object expected' error message. Is there a
way to fix this?
Thanks,
Bhavna
Jul 21 '06 #9

v.********@gmai l.com wrote:
ple help me anyone

i am using ms access database

tqty is text fields

rsCount.open "Select Sum(TQty) as temp from tbl_style where IPomsID="&
cdbl(request("I PomsID")),con,2 ,3

when i am exeuting query it gives below error

Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.

Please don't append your question to other threads unless they are
relevant to that thread. Start a new thread instead.

Change TQty to a numeric field. You can't add text fields up as if
they are numbers.

--
Mike Brind

Jul 21 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1535
by: JJP | last post by:
hi, I am searching a SQL database from an ASP page. When the user enters criteria with an apostrophe in it, result set is empty when there should be records. For example, the SQL database contains the record Children's Museum When a search is done without an apostrophe i.e. "children", the record is returned. When a search is done with an apostrophe i.e. "children's", the record is NOT returned.
3
5809
by: Peter Choe | last post by:
i am trying to add a record of a name. the name has an apostrophe (O'Neil). i am doing this through a servlet and wrote the code to use PreparedStatement. when i do: .... PrepareStatement pstmt = con.prepareStatement("INSERT INTO directory (name, phone) VALUES (?,?)");
2
8094
by: CSDunn | last post by:
Hello, I have a combo box designed to look up records in a subform based on the selection made in the combo box. The Record Source for the combo box is a SQL Server 2000 View. There is one bound column for the combo box called 'StudentName', and is a concatenated field comprised of 'LastName','FirstName'. These two fields are both the same datatype, 'nvarchar'. I have run into a problem when either the 'FirstName' or 'LastName' contains...
13
11388
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices Restaurant" etc. automatically and programmatically during data entry? This would eliminate my concatinated strings from producing errors when I base the string on a query. Think this is an example of the "Dreaded Apostrophe Bug." If I enter a...
1
2741
by: geodev | last post by:
I’m copying data across from an Access database to an MSDE database through the use of some vb.net code. Unfortunately the application crashes when it goes to copy across data, in particular surnames that have an apostrophe such as O’Shay etc. Also I have a ‘date/time’ value in my Access database that I have to copy across to my MSDE database in a field that is of datatype ‘datetime’ and length ‘8’. How do I get this...
0
2060
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records from database to a VB.net app, they retrieve the database fields as a record set eg. "select name, suburb from myTable"
3
2146
by: travellinman | last post by:
Hi, currently i'm using the code below to select a record in a form by using a drop down box. However, when there is an apostrophe ( ' ) in the value of the selected record i get an error code. So for example: Burger King would work perfectly, but McDonald's would give me an error... How do i get around this? Thanks! Private Sub Combo41_AfterUpdate() ' Find the record that matches the control. Dim rs As Object
3
4918
by: pitchblack408 | last post by:
Hello I am using excel as my database and when I do an insert there is an apostrophe that appears in the cell where a string was inserted. For example '(474)343-3433 It appears that the apostrophe appears after an insert is done that with a null value. example (424)333-3433 '(474)343-3433 '(424)343-3333
9
35458
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows() Method of the Recordset Object. This Method varies slightly from DAO to ADO, so for purposes of this discussion, we'll be talking about DAO Recordsets. The ADO approach will be addressed in the following Tip. We'll be using a Query, consisting of 5...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.