|
-
April 21st, 2011, 11:38 PM
#1
Redfine the database location
Nice to meet u all
i'm facing the problem of data table. I want to redfine the database location. It means i want to select database each time from application directory.
How can we re-define the location of database in it while loading specific form.
-
April 22nd, 2011, 02:40 AM
#2
Re: Hi ! Every body
I'm not 100% sure what you're asking. Maybe this will point you in the right direction:
Use an OpenFileDialog object called in Form_Load()... something like...
Code:
string dbPath;
public void Form_Load()
{
//Prompt the user to select the database to open in this form
OpenFileDialog ofd = new OpenFileDialog();
DialogResult dr = ofd.ShowDialog();
if( dr != DialogResult.OK )
//Kill the form
this.Unload(); //I think
//Otherwise read the path to the database
dbPath = ofd.FileName;
//Do some validation here
}
If, instead, you're asking how to pass in an argument to a newly created form: I have forgotten the design pattern to do that (I don't do a lot of forms programming), but I'm sure someone else here can tell you. It's simple, at any rate. You can probably google for it.
If, instead, you want to open it based on the application directory path, see my reply to your other recent post.
Hope that helps?
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
-
April 22nd, 2011, 05:22 AM
#3
Re: Hi ! Every body
i want to get the directory location of current program. How can i get it.
-
April 22nd, 2011, 03:45 PM
#4
-
April 23rd, 2011, 03:33 AM
#5
Re: Hi ! Every body
A good way, IMHO, is to store the Database location in your App.Config file, like this :
http://www.ezzylearning.com/tutorial.aspx?tid=8067328
This ensures that when the app starts up, it already knows where the DB is.
-
April 24th, 2011, 04:27 AM
#6
Re: Redfine the database location
thank you dear friend
It's good way...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|