Friday, February 24, 2012

Error "An attempt to attach an auto-named database for file"

Hello,

I have seen some solutions of which I tried on this form for the error I am receiving, but I still cannot get the issue resolved.

Here is my case:

I developed an app using SQL Express as the local data source. I published it to my server using the Once Click install feature. When I look in my project viewer, under settings, My db connection strings are listed as follows: Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TAP_Master.mdf;Integrated Security=True;User Instance=True

From another computer, I navigate to the publish site, install and run the application with no problems. I have on another computer, the same app with an updated version number that I wish to publish, however the difference is is that this published version does not include the database as I do not want the end user to overwrite any existing data that they may have from the previous version.

I publish the updated version, install it but when the app runs, I receive the message, "An attempt to attach an auto-named database for file".

Any suggestions?

Thanks in advance.

Rashar wrote:

I have on another computer, the same app with an updated version number that I wish to publish, however the difference is is that this published version does not include the database as I do not want the end user to overwrite any existing data that they may have from the previous version.

Please explain what this means. What do you mean by "another computer" is this a different computer than your development computer and the end-user computer? How did you create this updated version of the application, did you just remove the database or did you create a copy of the project?

When you install this "update" is it really updating the original deployment or is it installing a completely separate copy of the program?

Shrot answer: I don't think ClickOnce works like this from a VS perspective. I know it doesn't work like this from a SQL perspective. If you remove the database from your project and redeploy, I believe the database will actually be removed. (I say "belive" because I've never tried this.) You might want to consider an alternate way to deploy your database, I've documented one alternative in my blog, start with this post.

Mike

|||

Yes... It is a different computer from my development computer. Basically, I have the same code on both the development pc and the other pc... The reason being is that on my development pc, I would publish the entire app the database included. The problem I ran in to was if I made a change to the database on the development PC, published it, then have the client pc update their app, it would for some reason give them a new database overwriting any existintg data. It actually worked for me this way, until I decided to establish 2 different publishing locations, and I think that is where my problem lies.

Thanks for your reply and advice Mike!

Regards.

|||

I found the problem. When I published the second time around, the publish created an empty folder under C:\Documents and Settings\username\Local Settings\Apps\2.0.

So I just copied my database into that folder and it worked.

|||

I hadt he same problem en found thefollowing sollution:

This is what I found in web.config

<connectionStrings>

<add name="JopieString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Joop.mdf;Integrated Security=True;User Instance=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

|DataDirectory| is the directory of visual webdeveloper.

Delete this and type the name of the path in which your database is stored (in my case c:\inetpub\wwwroot\etc.)

<connectionStrings>

<add name="JopieString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\inetpub\wwwroot\App_Data\Joop.mdf;Integrated Security=True;User Instance=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

This solved the problem for me, I hope it also solves yours.

No comments:

Post a Comment