After making a DataSet and TableAdapter for my access or SQL database file. Where should we place the address of database file. Currently my program works only if database file is in exe folder. What if it is not local?
After making a DataSet and TableAdapter for my access or SQL database file. Where should we place the address of database file. Currently my program works only if database file is in exe folder. What if it is not local?
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
perhaps you can add the file as a resource, or integrate a file dialog or something to load the file.
I guess this is a perfect example for a config file.
Real short example : http://www.ajaxline.com/node/258
Short example: http://www.ezzylearning.com/tutorial.aspx?tid=8067328
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
All of the writings in config files and cs files about data access (database, dataset, datatable) are done by VS designer. There it puts a "|DataDirectory|" in connection string. In run time this phrase will be mapped to working directory instead of my database file directory.
I should not change the designer-generated code. But I did and replaced "|DataDirectory|" by my database file path. Now program works correctly. But there should be another way to tell the designer to do so, I think!
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
From a thred in MSDN forum. I learned:
-DataDirectory is a property of ApplicationDeployment in System.Deployment.Application NameSpace. But with only get accessor.
-We should set it when the program starts with
I don't know why it is not documented in MSDN or maybe I just can't find it.Code:AppDomain.CurrentDomain.SetData("DataDirectory", @"C:\DatabasePath...");
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C