Adding support for AttachDbFilename

Topics: Developer Forum
Nov 16, 2006 at 5:41 PM
I'm using SQL Express and was trying to deploy to filebased DB which the command-line utility didn't support, so I changed the lines of code that builds the ConnectionString to the following:

string dbfile = arg"dbfile".Value;
string connectionString = string.Format(@"Data Source={0};", server);
connectionString+=string.Format(@"Initial Catalog={0};", db);
connectionString+=string.Format(@"AttachDbFilename={0};", dbfile);
if (login.Length == 0)
connectionString += "Integrated Security=SSPI;";
else if (!string.IsNullOrEmpty(dbfile))
connectionString += "Integrated Security=True;User Instance=True";
connectionString += string.Format("User ID={0};Password={1}", login, password);

This enables me to deploy using:
msscmd -deploy -server=.\SQLExpress -dbfile=c:\MyWebApp\App_Data\GisDatabase.mdf
Nov 17, 2006 at 12:34 PM
Thank you. I will add this feature for the next release.
Nov 20, 2006 at 5:13 PM
Hmm it might not be that easy. Although I got it to deploy, making an ASP.NET application running with assemblies that require external access in a filebased database give me so many assembly security issues that I gave up and added it permanently to the database service.

If anyone have some good pointers on making this work, I'd love to hear them.
Nov 22, 2006 at 3:39 AM
Ok, I thought the snippet you provided was the current solution. Please, could you detail the security issues you faced? This could help someone else trying to do the same...

Best regards,
Ricardo Stuven.
Nov 22, 2006 at 4:51 AM
Not really. I never found a solution. All I found was a page stating that it requires some extra workarounds to allow for EXTERNAL_ACCESS with AttachDbFilename in an ASP.NET app.