I have a really simple question here, but I just can't find an answer that solves it.
I have a connection string like this:
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DB\DB.mdf;Initial Catalog=DB;Integrated Security=True");
It works, but when I try to use it in a PC that doesn't have SQL Server Express installed, it just won't connect. It'll obviously work if I remove that "\SQLEXPRESS" piece, I know, but I'd prefer not to do it manually on each PC I install the software. I tried to do it by using try-catch, but it's too slow and I think it isn't very recommended.
Well, I just want to know how to do it via code. Is there a simple way to do so? Will it solve the problem completely? (I mean, will it certainly work in other editions?)
Thanks in advance! (And sorry for my English)