Windows Develop Bookmark and Share   
 index > Windows Forms General > Ms Access Database Connection String
 

Ms Access Database Connection String

Hi,

I am developing an application with Ms Access .mdb database. Well i can connect to the database using the physical path. Now the problem is i am configuring the application for client server. So for every client i have to specify the physical path. Is there no way of providing the paths like we have in sql server where in we specify the server name (the computer wr the database will be)... or is there any other better way to do it?

plz help.

thanks,
Imran
MigrationUser 1  Wednesday, April 20, 2005 9:16 AM
A lot of people prefer registry keys, but the ".net way" is to utilize the app.config of your application.  On start up of your application, it will read the app.config file (in compile it's [yourappname].exe.config.  To do this, just add an app.config file into your application, and add the following child node.


<AppSettings>
    <add key="connstring" value="yourNewConnectionString" />
</AppSettings>


Retrieval would go something like..

string connString = System.Configuration.ConfigurationSettings.AppSettings.Get("connstring");

Here's MSDN's rock your socks explanation.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriintroductiontoapplicationsettingstorage.asp
MigrationUser 1  Wednesday, April 20, 2005 1:12 PM
Hi Again,

Thanks a lot for the information. Now i know how to do it but i am not able to find app.config in my project. Do i need to add it. But the visual studio.net does not show me .config files in add new item thingy.

Plz advice.

Thanks Again,
imran
MigrationUser 1  Wednesday, April 20, 2005 9:52 PM
Yes you need to add it, and select it from "Add/ New Item"
MigrationUser 1  Wednesday, April 20, 2005 10:31 PM
This site will help you out:

http://www.connectionstrings.com
MigrationUser 1  Saturday, April 23, 2005 8:32 PM

You can use google to search for other answers

Custom Search

More Threads

• Filtering Parent row values based upon existing child value
• Transparent Background Label
• Which code has to be executed on the UI thread?
• Sorting TabPages
• calling function in form
• BarBreak not implemented?!?!?!
• MDI Control Box Behavior
• Toolbar - Toolstrip
• MsAccess automation problem in vb.net
• XML.XMLDocument Alternatives Help!