SQL database
-
Pls guys, i wrote some code which is supposed to be installed on other computers. but when i finished, it could only run on my system, and generates SQL database errors when installed on other systems. the code was written in C#, i used the sql compact server that comes with visual studio 2008.this is how i wrote the connection string:
private static string connectionString()
{
string conString = @"Data Source=|DataDirectory|\electionsoft.sdf;Password=emejulu.4190;Persist Security Info=True";
return conString;
}private void openConnection() { if(con.State == ConnectionState.Closed) con.Open(); }
-
Pls guys, i wrote some code which is supposed to be installed on other computers. but when i finished, it could only run on my system, and generates SQL database errors when installed on other systems. the code was written in C#, i used the sql compact server that comes with visual studio 2008.this is how i wrote the connection string:
private static string connectionString()
{
string conString = @"Data Source=|DataDirectory|\electionsoft.sdf;Password=emejulu.4190;Persist Security Info=True";
return conString;
}private void openConnection() { if(con.State == ConnectionState.Closed) con.Open(); }
What errors? What OS on the target? Did you actually set the DataDirectory value somewhere? (Or did you forget to do that like I forgot to do that a while back?)
I thought you had to go to Pittsburgh for that. My Mu[sic] My Films My Windows Programs, etc.
-
Pls guys, i wrote some code which is supposed to be installed on other computers. but when i finished, it could only run on my system, and generates SQL database errors when installed on other systems. the code was written in C#, i used the sql compact server that comes with visual studio 2008.this is how i wrote the connection string:
private static string connectionString()
{
string conString = @"Data Source=|DataDirectory|\electionsoft.sdf;Password=emejulu.4190;Persist Security Info=True";
return conString;
}private void openConnection() { if(con.State == ConnectionState.Closed) con.Open(); }
Emejulu JVT wrote:
Source=|DataDirectory|\electionsoft.sdf
Where does the 'DataDirectory' get put at? It's likely to be a permissions issue on Vista / Windows 7 if this is in the program files directory. Just guessing here as the actual error message was not included in the post.
Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
-
What errors? What OS on the target? Did you actually set the DataDirectory value somewhere? (Or did you forget to do that like I forgot to do that a while back?)
I thought you had to go to Pittsburgh for that. My Mu[sic] My Films My Windows Programs, etc.
The OS i'm using is Win7. How do i set the DataDirectory value
-
The OS i'm using is Win7. How do i set the DataDirectory value
Put this somewhere where it will run before doing any database stuff:
AppDomain.CurrentDomain.SetData("DataDirectory", System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData));//LocalApplicationData));
Depending on whether you're installing for "everyone" or for each individual user, choose the CommonApplicationData or LocalApplicationData "SpecialFolder" there at the end. And, of course, that's where the database file has to sit. (which makes debugging from within Visual Studio a pain in the butt.)
I thought you had to go to Pittsburgh for that. My Mu[sic] My Films My Windows Programs, etc.