hon67
asked on
CDaoRecordset::FindFirst!!!
Dear All,
I have used the funciton FindFirst in order to locate the first matching method in my database and then update it with some data input by the user.
But I found that if the orginial data contain ' in the orginial data,
then no matching method can be found!!! Also, the return value of this function will not be equal to zero. It will udpate the first record of my database.
eg.
BOOL Find m_RsList->FindFirst([Telep hone Number]='107' AND [First Name]='Win's' AND [Last Name]='Poon');
In the field "First Name", the content is Win's ....
How can I solve this problem?
Thanks!!!!
I have used the funciton FindFirst in order to locate the first matching method in my database and then update it with some data input by the user.
But I found that if the orginial data contain ' in the orginial data,
then no matching method can be found!!! Also, the return value of this function will not be equal to zero. It will udpate the first record of my database.
eg.
BOOL Find m_RsList->FindFirst([Telep
In the field "First Name", the content is Win's ....
How can I solve this problem?
Thanks!!!!
What do you mean by, "But I found that if the orginial data contain ' in the orginial data, then no matching method can be found!!!"?
"Win's" instead of 'Win's'
If it will not help try
[FirstName] LIKE "Win's%"
If it will not help try
[FirstName] LIKE "Win's%"
try to replace any ' to ''
it is easy to replace that ', right?
for example:
BOOL Find m_RsList->FindFirst([Telep hone Number]='107' AND [First
Name]='Win''s' AND [Last Name]='Poon');
for SQL thinks ' is a beginning or end of a string
:)
hope it is helpful to u
it is easy to replace that ', right?
for example:
BOOL Find m_RsList->FindFirst([Telep
Name]='Win''s' AND [Last Name]='Poon');
for SQL thinks ' is a beginning or end of a string
:)
hope it is helpful to u
ASKER
For inputting a statement in the FindFirst function, I found that I can't use the character (") in the statement...
For exampel
m_RSList->FindFrist("[Tele phone Number]='107' AND [First Name]='Win"s' AND [Last Name]='Poon');
After modifying this, the progam cannot be complied.
What can I do to solve my problem?
For exampel
m_RSList->FindFrist("[Tele
After modifying this, the progam cannot be complied.
What can I do to solve my problem?
ASKER
For inputting a statement in the FindFirst function, I found that I
can't use the character (") in the statement...
For example
m_RSList->FindFrist("[Tele phone Number]='107' AND [First
Name]='Win"s' AND [Last Name]='Poon'");
After modifying this, the progam cannot be complied.
What can I do to solve my problem
can't use the character (") in the statement...
For example
m_RSList->FindFrist("[Tele
Name]='Win"s' AND [Last Name]='Poon'");
After modifying this, the progam cannot be complied.
What can I do to solve my problem
> For example
>
> m_RSList->FindFrist("[Tele phone Number]='107' AND [First
Name]='Win"s' AND [Last Name]='Poon'");
Try the following:
m_RSList->FindFrist("[Tele phone Number]='107' AND [First Name]=\"Win's\" AND [Last Name]='Poon'");
>
> m_RSList->FindFrist("[Tele
Name]='Win"s' AND [Last Name]='Poon'");
Try the following:
m_RSList->FindFrist("[Tele
ASKER
After try this:
m_RSList->FindFrist("[Tele phone Number]='107' AND [First
Name]=\"Win's\" AND [Last Name]='Poon'");
The record can be updated succesfully....but if the data become like this W"in's
m_RSList->FindFrist("[Tele phone Number]='107' AND [First
Name]=\"W"in's\" AND [Last Name]='Poon'");
No matching record can be found!!!
Thus how can I use the FindFirst Function to find the matching record when the data at one of the fields contain both the ' and " characters.....?
Thanks!!!
m_RSList->FindFrist("[Tele
Name]=\"Win's\" AND [Last Name]='Poon'");
The record can be updated succesfully....but if the data become like this W"in's
m_RSList->FindFrist("[Tele
Name]=\"W"in's\" AND [Last Name]='Poon'");
No matching record can be found!!!
Thus how can I use the FindFirst Function to find the matching record when the data at one of the fields contain both the ' and " characters.....?
Thanks!!!
Are you sure you realy have record with
([Telephone Number]='107' AND [First Name]='Win's' AND [Last Name]='Poon')
1) Is [Telephone Number] the field name?
2) Is it contain just '107'? (maybe LIKE '107%')
3) Is it text field?
4) Is the record you searching contain ALL three fields mentioned EXACTLY?
-------------------------- -----
Thus how can I use the FindFirst Function to find the matching record when the data at one of the fields contain both the ' and " characters.....?
-------------------------- ------
Try to replace all 's with +CHR(39)+
or all "s with +CHR(34)+
([Telephone Number]='107' AND [First Name]='Win's' AND [Last Name]='Poon')
1) Is [Telephone Number] the field name?
2) Is it contain just '107'? (maybe LIKE '107%')
3) Is it text field?
4) Is the record you searching contain ALL three fields mentioned EXACTLY?
--------------------------
Thus how can I use the FindFirst Function to find the matching record when the data at one of the fields contain both the ' and " characters.....?
--------------------------
Try to replace all 's with +CHR(39)+
or all "s with +CHR(34)+
TRY using LIKE "*107*" for tel number
LIKE "*Win's*"
([Telephone Number] LIKE "*107*" AND [First Name] LIKE "*Win's*" AND [Last Name] LIKE "*Poon*")
place \ before each " for query string.
Note that Access use * as wildcard for any sequence of characters while SQL server use %.
LIKE "*Win's*"
([Telephone Number] LIKE "*107*" AND [First Name] LIKE "*Win's*" AND [Last Name] LIKE "*Poon*")
place \ before each " for query string.
Note that Access use * as wildcard for any sequence of characters while SQL server use %.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try to replace all 's with +CHR(39)+
thus
....[First Name]='Win'+CHR(39)+'s' ...
thus
....[First Name]='Win'+CHR(39)+'s' ...