How To : Fix “Format of the initialization string does not conform to specification starting at index 0.” error

When you work woth connection strings it is likely that at some point you get this error.

“Format of the initialization string does not conform to specification starting at index 0.”

The cause of the error may one of the following.

  • You supplied wrong connection string – Always test your connection string using some database tool or get the one VS is creating for you. Thats what I do.
  • Check your DataControl – SqlDataSource in my case if it is using correct connection string.
  • Check the connection string that you supply in code. You may have missed something.

A good practice is to place all your connection strings in config file and reference then using System.Configuration classes.
simple as this
string connectionString = ConfigurationManager.ConnectionStrings["connectionString1"].ConnectionString;

You will have to add reference to the project and then using statement to System.Configuration.

Happy coding

This entry was posted in Uncategorized. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>