Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all

I have create an access connection to load my data with datagridview

My original path is in c:\
Is there any way to change tis path from my first screen.......

Thanks and regards.
Posted

1 solution

If the Access file in in C:\, then why would you want to change this path? Or do you mean you want to copy the file elsewhere and then access it from there? If so, just copy the file over and set your connection string accordingly. If there's somethign I missed in your rather vaguely phrased question, please improve your question and add more info.

[Update]
---------

In response to your comment:

So during development, you are hardcoding a path to C:\ but once deployed you'd like the user to specify a custom path? If so your ini file approach should work well. In .NET the recommended approach is to user app.config files. But ini files will work too. At startup, read the path to the mdb file and then use that when you connect to the database.

You wanted a class for reading INI files. Here's a popular article on CP that does that:
An INI file handling class using C#[^]

And here's an article that shows how to connect to Access from code (using VB.NET):

http://www.startvbdotnet.com/ado/msaccess.aspx[^]
 
Share this answer
 
v5
Comments
Vagelisr 20-Apr-11 10:42am    
Now i want my database in C:\
But when the program is OK i want to put the database in another location.
I can create 1 ini file and put the path in ini file but how can i change the path from my main screen??
Nish Nishant 20-Apr-11 10:50am    
So during development, you are hardcoding a path to C:\ but once deployed you'd like the user to specify a custom path? If so your ini file approach should work well. In .NET the recommended approach is to user app.config files. But ini files will work too. At startup, read the path to the mdb file and then use that when you connect to the database.
Vagelisr 20-Apr-11 10:54am    
Can you write the command.....

Thanks a lot for your time..........
Nish Nishant 20-Apr-11 10:56am    
There's already a class here on CP that helps with reading ini files :

http://www.codeproject.com/KB/cs/cs_ini.aspx
Vagelisr 20-Apr-11 10:59am    
I knew hot to read ini file. I don't knew how to said in vs 2008 that my database in not in c:\ but in c:\something\something

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900