tags:

views:

35

answers:

2

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`
A: 

I don't know if this is possible or not, but I do know that the OleDb Connection object in .Net has a property called Provider that will tell you what kind of database you are connecting to.

Mark Ewer
+1  A: 

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.

Mark Wilkins