Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

Has it ever happen that you have made the Access database connection and it worked on your local machine and blows on the development server? I am using the connection string in two parts take a look at the code below: 

add key="ConnectionString" 
 User Id=admin;Password=;Data Source=" />
add key="ConnectionPath" value="/Database/MyDatabase.mdb" />

And here is the C# code that combines and build up the connection string.

// generates the connection string 
private string GenerateConnectionString() 
string provider = (string
string path = (string) ConfigurationSettings.AppSettings["ConnectionPath"]; 
string connectionString 
= provider + HttpContext.Current.Server.MapPath("~/"+path); 
//string connectionString = provider + path;     
return connectionString; 

Hope it helps!  


powered by IMHO 1.3

Posted on Friday, February 17, 2006 11:19 PM | Back to top

Comments on this post: Connection String problems for Access Database

# re: Connection String problems for Access Database
Requesting Gravatar...
Hi Azam,
I've mostly been programming on recently Ive switched to c#.
When you declare a variable like
string provider = (string)
what is this (string) there? what does that signify?
Sorry about this very lame mans question :-)
I thought we generally put like that to cast from one type to another...but Ive not seen in many places declaration this way..please tell me what it means..Thanks
Left by Godwin on Feb 17, 2006 11:21 PM

# re: Connection String problems for Access Database
Requesting Gravatar...
Hi Godwin,

Ohh I think you are refering to my line:
string provider = (string)

This is one single line simply spanned into two because of less space. And yes you are correct that its used for casting nothing else.
Left by azamsharp on Feb 18, 2006 7:01 AM

# re: Connection String problems for Access Database
Requesting Gravatar...
Great tip - I normally use something very similar to this in a singleton implementation, but I had missed the tilde (~) thingy, which now makes things so much easier!
Left by Jannik Anker on Feb 19, 2006 3:12 AM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: