Encase Query Names in Brackets to Avoid ADO/Jet Errors

Encase Query Names in Brackets to Avoid ADO/Jet Errors

While using OLE DB Provider for Jet to manage Access databases through ADO from VB, follow this tip to help you access a query defined in your database. If the query name contains blank characters (ASCII code 32), supply this code, enclosing the name in brackets:

 'To access the query by the 'Recordset object's Open method:rs.Open "[Name with blanks]", _ 'Etc.'To access the query by a Command object:cm.CommandText = "[Name with blanks]"

If you don’t, your program will show a runtime error when you try to open the recordset. The OLE DB Provider for Jet databases interprets the supplied string as a SQL statement, which doesn’t match that language syntax. Specifying different values for the Command object’s CommandType property?or specifying different values on the Options argument when invoking the recordset’s Open method?doesn’t fix the problem. You must use the brackets.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular