Part of your problem is you have a trailing '.' in your IP address. Remove that like so:
"Data Source=127.0.0.1;" +
"Initial Catalog=Filter;" +
"Integrated Security=SSPI;";
Also, I would strongly suggest that you wrap your connection object in a using statement like this:
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString =
"Data Source=127.0.0.1.;" +
"Initial Catalog=Filter;" +
"Integrated Security=SSPI;";
conn.Open();
}
Lastly, define your connection in a string and pass it into your SqlConnection object when you instantiate it, like this:
string sqlConnection = "Data Source=127.0.0.1;Initial Catalog=Filter;Integrated Security=SSPI;"
using (SqlConnection conn = new SqlConnection(sqlConnection)
{
conn.Open();
}
This approach does several things for you:
- It makes your code much, much easier to read, and clean.
- It ensures that your connection object will get handled by
Dispose even if there is an exception thrown in the using block.
- It is just a good habit to get into early.
More on the SqlConnection class here, and more on using can be found here.
Data Source=<yourcomputername>doesn't work then try putting the path to the mdf file. E.g.Data Source=C:\Data\Filters.mdf. I'm guessing that the reason the UI thread stops is because the default connection timeout is 30 seconds, so the connection has 30 seconds to respond before .net throws an exception.