views:

246

answers:

1

Given any DbConnection from any Data Provider, is it possible to determine the character or characters used to quote a string literal as well as escape any special characters within the string? I'm also interested in the characters necessary for quoting schema/table/column name identifiers.

Using parameters to specify these things is not an option as the intent of my application is to help users build a SQL query and having constants within the query is a common scenario.

I can use the DataSourceInformation schema collection to get something like StringLiteralPattern and QuotedIdentifierPattern (see http://msdn.microsoft.com/en-us/library/ms254501.aspx) but that only helps me match existing strings and not create them myself.

A: 

I use a switch statement depending upon provider type and version (as determined from DbConnection) in order to know what delimiters/escape characters to use.

RedFilter