procopio
March 5th, 2010, 09:52 AM
Hi, here is a sample code. Please see the path to the datasource, it is very long, and if i will be deploying the application on other computer , the path would not be the same anymore.
SqlCeConnection conn = new SqlCeConnection(@"Data Source = C:\\Users\\Kiko\\Documents\\Visual Studio 2008\\Projects\\DelegaitAMS\\DelegaitAMSystem.sdf");
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = string.Format(@"INSERT INTO Office(office_name)" +
"Values('{0}')", txtbxOfficeName.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Now if I was to compile this code, and put the .exe on another PC, when I run it, it will be searching for that filepath for the db which wont be there :S But the DB will be, as it will be included in the program when it is compiled.
Basically, is there a generic filepath that will always link to the DB in the compiled code/program?
Please help me with my problem, i need this for my project.
SqlCeConnection conn = new SqlCeConnection(@"Data Source = C:\\Users\\Kiko\\Documents\\Visual Studio 2008\\Projects\\DelegaitAMS\\DelegaitAMSystem.sdf");
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = string.Format(@"INSERT INTO Office(office_name)" +
"Values('{0}')", txtbxOfficeName.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Now if I was to compile this code, and put the .exe on another PC, when I run it, it will be searching for that filepath for the db which wont be there :S But the DB will be, as it will be included in the program when it is compiled.
Basically, is there a generic filepath that will always link to the DB in the compiled code/program?
Please help me with my problem, i need this for my project.