I have a working SQL connection here: 

```
SqlConnection conn = 
   new SqlConnection(@"server=localhost\SQLEXPRESS;
                       AttachDbFilename=C:\Seach ENGINE (June 22, 2015)\SE\SE\MainDatabase.mdf;
                       Integrated Security=True;User Instance=True");

```

but the problem is I need to provide the complete path. Unlike asp.net, all I have to do is to add `|DataDirectory|` to it and include the database name .. 

Then I tried to use the `|DataDirectory|` in this connection string and I get an error: 

> 
> invalid value for key 'attachDbFilename'
> 
> 
> 

I published my application and I can't locate the database now because I installed it in a different computer.. so the `attachDbFilename` is not true .. 

If the `DataDirectory` is not working is there any other code that I can use similar to data directory?