Reputation: 41
I made an application with animations in WPF with Visual Studio 2008 Team System and SQL Server 2005.
So I have Windows XP and Windows 7, in Windows XP that I have Visual Studio and SQL Server and Framework 3.5 it works very well, but in Windows 7 and in other computers it can not connect to database, first I thought it's about Framework but in other computers I have this problem again.
My connection string is:
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"|DataDirectory|safedb.mdf\";Integrated Security=True;Connect Timeout=30;User Instance=True";
What do you think? I must install Visual Studio in every computer?
What is the problem?
this is the code of that button which has error in another computer that doesn't have Visual Studio :
login l = new login();
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"|DataDirectory|safedb.mdf\";Integrated Security=True;Connect Timeout=30;User Instance=True";
con.Open();
String sql = "EXEC GetLoginModel";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
da.Fill(ds);
bool n = (bool)ds.Tables[0].Rows[0].ItemArray[0];
bool s = (bool)ds.Tables[0].Rows[0].ItemArray[1];
l.radioButton1.IsEnabled = n;
l.radioButton2.IsEnabled = s;
con.Close();
this.Close();
l.Show();
yes I knew but i thought we need this program only when we want to make databases not using it ...
i saw a lot of softwares that they work with mssql but they are tiny and they don't need any other program to install ???
so what ?
and please give me the link of sql server express edition only for using with my app ...
it means i must place that besides of my app ???
Thanks A Lot Again My Sweet Friend :X
Upvotes: 0
Views: 1401
Reputation: 755381
Do you have this database safedb.mdf
on every computer? That would be the first thing to
check..... (since you're attaching a local database file - not connecting to a central server)
OK; so you do have the files on all computers.
Next question: you mention you get an error on the "other" computers.
WHAT is the error exactly? Can you give us the exact error message, an error code possibly?.....
I almost don't dare to ask: you do know that in order to attach a SQL Server Express database on a computer, you have to have SQL Server Express installed on that machine?? Have you installed it as the "SQLExpress" named instance on each and every machine?
I ask since you only mention "WPF" and ".NET Framework 3.5" (which both don't include SQL Server Express........)
Windows 7 comes with the .NET Framework 3.5 Service Pack 1 pre-installed, so you definitely have .NET and WPF on those computers right from the beginning....
Marc
Upvotes: 2