This project is read-only.

Adding support for AttachDbFilename

Topics: Developer Forum
Nov 16, 2006 at 6: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);
if(string.IsNullOrEmpty(dbfile))
connectionString+=string.Format(@"Initial Catalog={0};", db);
else
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";
else
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 1:34 PM
Thank you. I will add this feature for the next release.
Nov 20, 2006 at 6: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 4: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 5: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.