Click to See Complete Forum and Search --> : Brackets messing up my SQL query
scottdw
01-23-2007, 11:11 AM
This is a very basic question I am sure but I am just starting all this :)
I have this SQL Query:
rs.Source = "SELECT * FROM NC_Workstation WHERE ClientID = '{099F4671-406F-4231-B234-4D7B6EB9F8D2}'"
The {}'s are part of the data not the code, in other words the ClientID field in the database reads: {099F4671-406F-4231-B234-4D7B6EB9F8D2}
How do I make the {}'s show as I need. I am pretty sure they are what is messing up my query.
Hope that makes sense!!!
russell
01-23-2007, 11:50 AM
that ought to work. what is the problem? any error?
scottdw
01-23-2007, 12:07 PM
Thanks for the reply.
I get:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
If I use another field it works fine. That is why I thought the {}'s or the formatting of the data was off.
One other thing is I don't know much about Access and if I look at the database itself with the field in question the "Data Type" is number and the "Field Size" is set to Replication ID.
Not sure if that matters or not but thought I would throw it out there.
Thanks for you help.
scottdw
01-23-2007, 01:05 PM
After researching a little more I think it is the Replication ID/GUID that is causing my problem but I don't know how to fix it.
russell
01-23-2007, 01:28 PM
remove the quotes from around the guid
SELECT * FROM NC_Workstation WHERE ClientID = {099F4671-406F-4231-B234-4D7B6EB9F8D2}
scottdw
01-23-2007, 01:44 PM
Ok I am getting closer. Now I am getting:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ClientID = 099F4671-406F-4231-B234-4D7B6EB9F8D2}'.
/pcsearchdetails.asp, line 21
My Line looks like this now:
rs.Source = "SELECT * FROM NC_Workstation WHERE ClientID = {099F4671-406F-4231-B234-4D7B6EB9F8D2}"
Thanks,
russell
01-23-2007, 02:01 PM
sorry, that works directly in msaccess, but via ADO needs to be like this
SELECT * FROM FROM NC_Workstation WHERE ClientID = '{099F4671-406F-4231-B234-4D7B6EB9F8D2}'
which is, i think, what u had in 1st place. no records were returned? maybe wrong guid...?
scottdw
01-23-2007, 02:13 PM
Yeah no records I get:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
I copied and pasted the GUID from the DB in the query so I sure it's right.
Sorry I thought it was something simple :)
russell
01-23-2007, 03:07 PM
can u execute the query in nsaccess directly. the error u r getting means there is no recordset returned. so it seems like wrong guid.
would need to see more of your code, but try executing in access