 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jon E. Scott Guest
|
Posted: Thu Jan 05, 2006 2:42 pm Post subject: Locate() with # and quotes causing ADO error |
|
|
I'm at a loss here. We read in XML files and locate values from the XML
files in our SQL database and add or edit the records as necessary. For
performance reasons because of many large XML files, we open our table using
SELECT * FROM ... and then TADOQuery.Locate() to locate the records rather
than filtering or straight SQL.
Sometimes the strings to locate can contain both the # char and quotes and
this causes an error: "Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another."
Example:
AdoQuery1.Locate('Field1', '''quoted string'' #1', [loCaseInsensitive]);
Doesn't work. If I either remove the quotes or the # char, Locate() will
work. We want to try to keep the string from the XML files exactly as they
are when posting to the database, but if stripping chars is the only way to
go then I guess we'll have to. Does anyone have any idea why ADO doesn't
like quotes *and* # char at the same time using Locate() and how to fix it?
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
|
|
| Back to top |
|
 |
Guillem Guest
|
Posted: Thu Jan 05, 2006 3:00 pm Post subject: Re: Locate() with # and quotes causing ADO error |
|
|
Jon E. Scott wrote:
| Quote: | I'm at a loss here. We read in XML files and locate values from the
XML files in our SQL database and add or edit the records as
necessary. For performance reasons because of many large XML files,
we open our table using SELECT * FROM ... and then TADOQuery.Locate()
to locate the records rather than filtering or straight SQL.
Sometimes the strings to locate can contain both the # char and
quotes and this causes an error: "Arguments are of the wrong type,
are out of acceptable range, or are in conflict with one another."
Example:
AdoQuery1.Locate('Field1', '''quoted string'' #1',
[loCaseInsensitive]);
Doesn't work. If I either remove the quotes or the # char, Locate()
will work. We want to try to keep the string from the XML files
exactly as they are when posting to the database, but if stripping
chars is the only way to go then I guess we'll have to. Does anyone
have any idea why ADO doesn't like quotes and # char at the same time
using Locate() and how to fix it?
|
try using QuotedStr instead of putting the quotes directly
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
|
|
| Back to top |
|
 |
Jon E. Scott Guest
|
Posted: Thu Jan 05, 2006 5:31 pm Post subject: Re: Locate() with # and quotes causing ADO error |
|
|
"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote
| Quote: |
try using QuotedStr instead of putting the quotes directly
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
|
Nope, doesn't work. It seems the problem lies in function GetFilterStr() in
ADODB.pas. The code looks for the quote char but doesn't take into account
that maybe the string already has the # char. I guess my only option is to
remove the quotes before calling Locate().
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
|
|
| Back to top |
|
 |
Vitali Kalinin Guest
|
Posted: Thu Jan 05, 2006 5:42 pm Post subject: Re: Locate() with # and quotes causing ADO error |
|
|
"Jon E. Scott" <NOSPAMsupport (AT) blueorbsoft (DOT) comNOSPAM> сообщил/сообщила в
новостях следующее: news:43bd5758$1 (AT) newsgroups (DOT) borland.com...
| Quote: | "Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:xn0egvlucgkqsn000 (AT) newsgroups (DOT) borland.com...
try using QuotedStr instead of putting the quotes directly
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
Nope, doesn't work. It seems the problem lies in function GetFilterStr()
in ADODB.pas. The code looks for the quote char but doesn't take into
account that maybe the string already has the # char. I guess my only
option is to remove the quotes before calling Locate().
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
I would suggest your to resort yours code to use Filter directly instead of |
Locate it could even increase performance.
|
|
| Back to top |
|
 |
Andrew Guest
|
Posted: Thu Jan 05, 2006 10:03 pm Post subject: Re: Locate() with # and quotes causing ADO error |
|
|
"Jon E. Scott" <NOSPAMsupport (AT) blueorbsoft (DOT) comNOSPAM> wrote
| Quote: | I'm at a loss here. We read in XML files and locate values from the XML
files in our SQL database and add or edit the records as necessary. For
performance reasons because of many large XML files, we open our table using
SELECT * FROM ... and then TADOQuery.Locate() to locate the records rather
than filtering or straight SQL.
Sometimes the strings to locate can contain both the # char and quotes and
this causes an error: "Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another."
Example:
AdoQuery1.Locate('Field1', '''quoted string'' #1', [loCaseInsensitive]);
Doesn't work. If I either remove the quotes or the # char, Locate() will
work. We want to try to keep the string from the XML files exactly as they
are when posting to the database, but if stripping chars is the only way to
go then I guess we'll have to. Does anyone have any idea why ADO doesn't
like quotes *and* # char at the same time using Locate() and how to fix it?
--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com
IIRC # is used by the JET engine to delimit dates, so it could be trying to parse the string as a date and throwing an error. The quotes may be trying to force the data into a string while the # may be forcing it to a date - hence an error ?? |
HTH
Andrew
|
|
| Back to top |
|
 |
mIKE Guest
|
Posted: Sat Jan 07, 2006 4:09 pm Post subject: Re: Locate() with # and quotes causing ADO error |
|
|
| Quote: | Sometimes the strings to locate can contain both the # char and quotes
and
this causes an error: "Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another."
Does anyone have any idea why ADO doesn't
like quotes *and* # char at the same time using Locate() and how to fix
it? |
| Quote: | IIRC # is used by the JET engine to delimit dates, so it could be trying to
parse the string as a date and throwing an error. The quotes may be
trying to force the data into a string while the # may be forcing it to a
date
- hence an error ??
|
Could this be another one of those cases where this pre-parsing is
unnecessarily done because ParamCheck was left as the default value of True?
What happens when it's changed to False?
mIKE
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|