right now I have the appconfig as
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\z1083774\Desktop\Data
\Database.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
I know I can put it in the root directory c:\ ,but i know there is another way to do it.
Sam HobbsPosted Mar 22, 2010, 9:40 PM
BangaruBabu PuretiPosted Mar 22, 2010, 4:56 AM
Let Me Explain
There is Beautiful Class Available in C# Windows To Detect Application Path Where The exe Gets installed
System.Windows.Forms.Application.StartupPath.ToString();
That Returns The Path As A String For Ur Application.U Just Append That mdf file name to The string.
example
=====
string constring=System.Windows.Forms.Application.StartupPath.ToString();
I Think it Resolves Ur Requirement.
feedback Always Expected
BangaruBabu Pureti
Hirendra SisodiyaPosted Mar 22, 2010, 4:42 AM
Hello Darnell
Please tell me how to distribute your application among your customer? with the help of setup file and database file or exe and databasefile???
thanks
David SmithPosted Mar 22, 2010, 4:07 AM
use this
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|CLU_OpDatabase.mdb"
so now im forcing the users to run the database where the exe is. which is what i prefer for this situation
Hirendra SisodiyaPosted Mar 22, 2010, 1:33 AM
you can place this line on your application startup form file for example if you are using any login form than you can place this line on login form load event or you can use in program.cs file.
thanks
David SmithPosted Mar 20, 2010, 12:13 PM
AppDomain.CurrentDomain.SetData("DataDirectory","C:\\Data\\bin\\Debug\\");
David SmithPosted Mar 20, 2010, 12:10 PM
Ok I have questions regarding your last reply so with this line of code below , does this mean they can run the executive from anywhere , whether its on the desk, in a temp directory no matter what. right how I got to set up is they have to have the .mdf file along with executive to run the .exe .
AppDomain.CurrentDomain.setData("DataDirectory","C:\\Data\\bin\\Debug\");
hello Darnell
try this:
|DataDirectory| is a substitution string that indicates the path to the database.
By default, |DataDirectory| is substituted with the base directory that the exe is running from.
you can set the custom path of its byusing this code(use this code on load time of your application):
AppDomain.CurrentDomain.setData("DataDirectory","C:\\Data\\bin\\Debug\");
and than write this connection string in your appconfig:
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Cif_Clu_Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
thanks
Hirendra SisodiyaPosted Mar 20, 2010, 5:04 AM
try this:
|DataDirectory| is a substitution string that indicates the path to the database.
By default, |DataDirectory| is substituted with the base directory that the exe is running from.
you can set the custom path of its byusing this code(use this code on load time of your application):
AppDomain.CurrentDomain.setData("DataDirectory","C:\\Data\\bin\\Debug\");
and than write this connection string in your appconfig:
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Cif_Clu_Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
thanks
please mark as answere if you like my answere
David SmithPosted Mar 20, 2010, 4:21 AM
David SmithPosted Mar 20, 2010, 3:23 AM
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\Data\\bin\\Debug\\Database.mdf\";Integrated Security=True;Conne" +
"ct Timeout=30;User Instance=True")]
and then in the appconfig I do this
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Cif_Clu_Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
how can i set it up to where they can just run the exe anywhere on the computer, what if they wanted to run the exe on the desktop, that mean they would to create a datafolder i dont want to do that,
just want to run from anywhere.
Amit ChoudharyPosted Mar 18, 2010, 1:14 AM
AttachDbFilename="\Data\Database.mdf";
Either create a folder names Data in the same folder where the exe is and set the path like this then you don't have to change the path every time you installed it.
Hope it helps you.
David SmithPosted Mar 17, 2010, 6:05 PM
Sam HobbsPosted Mar 17, 2010, 2:34 PM