Formating Rules for Connection Strings

This is general rules adopted by most drivers and providers. However, keep in mind that these rules is not 100% accurate for every driver and every situation. Never the less, following and knowing about these basic rules will keep some common problems out of the way.

The rules

  • All blank characters, except those placed within a value or within quotation marks, are ignored
  • Blank characters will though affect connection pooling mechanism, pooled connections must have the exact same connection string
  • If a semicolon (;) is part of a value it must be delimited by quotation marks (")
  • Use a single-quote (') if the value begins with a double-quote (")
  • Conversely, use the double quote (") if the value begins with a single quote (')
  • No escape sequences are supported
  • The value type is not relevant
  • Names are case iNsEnSiTiVe
  • If a KEYWORD=VALUE pair occurs more than once in the connection string, the value associated with the last occurrence is used
  • However, if the provider keyword occurs multiple times in the string, the first occurrence is used.
  • If a keyword contains an equal sign (=), it must be preceded by an additional equal sign to indicate that it is part of the keyword.
  • If a value has preceding or trailing spaces it must be enclosed in single- or double quotes, ie Keyword=" value ", else the spaces are removed.

Summary

Knowing about these basic rules will keep hard to track errors away from you. Take some time understanding these rules and a couple of minutes choosing what parameters to specify when connecting your application to the data source.

Connect

Articlesread all »

Not what you were looking for?

Browse the other articles in the knowledge base!

Or search kb articles, Q&A content and every connection string here.

Start over in the connection string reference or check out the Q&A forums where you can ask your own questions!