Search code examples
.netoledbquotes

Is it possible to query an OleDB connection to find out if you must use square brackets or quotes?


Is it possible to query an OleDB connection to find out if you must use square brackets or quotes?

SQL:

SELECT [FullName] From [My Users]

Oracle

SELECT "FullName" From "My Users"

MySQL:

SELECT `FullName` From `My Users`

Solution

  • OLE DB itself has the IDBInfo interface with the GetLiteralInfo method. A couple of the pieces of information in it are DBLITERAL_QUOTE_PREFIX and DBLITERAL_QUOTE_SUFFIX, which is the information you are looking for. If the provider you are using exposes that interface, then you should be able to access it through ADO via the OpenSchema method. The SchemaEnum contains adSchemaDBInfoLiterals, which should return a Recordset with the desired information.