PRB: Run-time Error '40002' When Querying on s_GUID field in RDO (197883)
The information in this article applies to:
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q197883 SYMPTOMS
When using the database replication feature of Microsoft Access, a
ReplicationID AutoNumber field is added to the database. The ReplicationID
AutoNumber field (s_GUID) is a 16-byte GUID (Globally Unique Identifier)
that uniquely identifies each record in the database.
If you are using RDO 2.0 to access the replicated database and you try to
search on the s_GUID field using the following syntax:
Set rdoRes = rdoConn.OpenResultset("select * from Nwind where
s_guid={guid{9B83B027-E038-11D1-847E-00C04FB1784E}}", _
rdOpenKeyset, rdConcurLock, rdAsyncEnable)
The following error occurs:
Run-Time error '40002':
37000: [Microsoft][ODBC Microsoft Access 97 Driver] Syntax error
(missing operator) in query expression 's_guid = guid
9B83B027-E038-11D1-847E-00C04FB1784E}'.
Notice that all of the curly braces have been stripped off except the last
one.
CAUSE
Because ODBC defines the curly brace as an escape code for vendor specific
escape clauses, you must turn off escape clause scanning when you use
literal globally unique identifiers (GUIDs) in SQL statements with the
Microsoft Access ODBC Driver. This is accomplished by using the
SQLSetConnectionOption API to turn off driver scanning for escape clauses.
STATUS
This behavior is by design.
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
170117 HowTo: Use GUID Fields in Access from Visual C++
Modification Type: | Minor | Last Reviewed: | 4/22/2003 |
---|
Keywords: | kbprb kbRDO KB197883 |
---|
|