Connection String Nightmares in Access Database

I never thought using connection string in web.config for Access database could be so frustrating. Whenever I put the connection string and try to feed it to the connection object it always throws the exeption that the path was not found even though I was using Server.MapPath. The problem was that you cannot feed the whole damn connection string to the map path method since it only takes a PATH and no junk. Hence I have to break it down into pieces. Something like this:
  
  
 
    
And then used the following code to retrieve the path information from web.config.
string provider = (string) ConfigurationSettings.AppSettings["ConnectionString"]; 
			string path = (string) ConfigurationSettings.AppSettings["ConnectionPath"]; 
			string connectionString = provider + HttpContext.Current.Server.MapPath(path); 
Finally it worked and I was a happy man :)

Print | posted @ Saturday, July 30, 2005 9:17 PM

Twitter