When I attempt to run the Time Tracker Starter kit I receive the following error:
An attempt to attach an auto-named database for file C:\WebSites\Test_TimeTracker\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I checked SQL Express and I did originally have a database named aspnetdb that was installed by the QuickStarts. I have subsequently detached that database and moved the data and log files from SQL Express's data folder, however I still get the same error.
I've opened mdf file in visual studio and verified that it did indeed contain data and was not corrupt. The directory is not in a UNC Share. I've granted full security access on the WebSites directory to the "Everyone" user.
I'm running Windows 2003 Standard Edition, using Visual Studio Team Suite, running under beta 2 of the Framework.
I imagine that I could attach the mdf in Sql Express and then rewrite the ConnectionString to point to that, but I'd like to get it to work the way it was intended. I've attached the Connection String section as well as the stack trace below. Does anyone
have any ideas about how to fix this issue?
I figured it out. I took a look at the connection string on the personal web site starter kit which is similar in the way that it connects to the database.
Apparently the Time Tracker Starter kit is missing the following option from its connections string.
"User Instance=True;"
Once I added this option to the Connection String everything works fine. So the new connectionstrings look like this.
That was one of the problems I was having when trying to run the app in my local IIS. After I changed the connection string, I got the same error message again, but this time with a different stack trace.
Then I read your post again, and went to look at my databases with SQL Express Manager, and noticed that aspnetdb was already running in it. I deleted the aspnetdb,, reinstalled blank mdf files for it and the timetracker db, changed the permissions so that
"Everybody" had full control to them, and then tested the app. I can now use it!
Can anyone tell me what the user instance=true part of the connection string does?
User Instance = true is described in this post on the MS news groups:
http://communities.microsoft.com/newsgroups/previewFrame.asp?ICP=sqlserver2005&sLCID=us&sgroupURL=microsoft.private.sqlserver2005.express&sMessageID=%253CuQCkdV5UFHA.2092@CPMSFTNGSA04.privatenews.microsoft.com%253E
The only times I have received this message have been when, after testing on my local server with it working perfectly, I have moved the application onto a remote test server and placed the application in a subfolder of the remote site.
This always generates this message.
After the data has been moved to the correct location (as it would be on a live server) or the test server location is identified in the web.config file then the problem has been resolved.
In each case the relevant part of the message was "or specified file cannot be opened"
as it is being told to look in the wrong location.
I have the same error after a current failure(my pc shat down suddenly)...my connection string is ok and I don’t know what's going wrong...
Any Ideas?
Thanks!!!
Hi, I'm wondering if there is corruption of theaspnetdb.mdf
file because of improperly shutting down, Please make sure
that the file is still exists under App_Data folder of your web application.
If it is, make a copy of it, though it might be corrupt already.
You can try attach your .mdf file with SQL Server.
You can try to
attach mdf only by using sp_attach_single_file_db
too if there is only one ldf file for the db.
If you are using SQL Server instead of SQL Server Express, please back up the last transaction log too.
Zhao Ji Ma
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
thanks for the answer but I haven't the file "aspnetdb.mdf " in my application directories...In addition,I use Sql Express Edition and I don't think is possible to attach my database file
...
Rich21
Member
260 Points
52 Posts
An attempt to attach an auto-named database for file ... failed
Apr 22, 2005 06:47 PM|LINK
When I attempt to run the Time Tracker Starter kit I receive the following error:
An attempt to attach an auto-named database for file C:\WebSites\Test_TimeTracker\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I checked SQL Express and I did originally have a database named aspnetdb that was installed by the QuickStarts. I have subsequently detached that database and moved the data and log files from SQL Express's data folder, however I still get the same error.
I've opened mdf file in visual studio and verified that it did indeed contain data and was not corrupt. The directory is not in a UNC Share. I've granted full security access on the WebSites directory to the "Everyone" user.
I'm running Windows 2003 Standard Edition, using Visual Studio Team Suite, running under beta 2 of the Framework.
I imagine that I could attach the mdf in Sql Express and then rewrite the ConnectionString to point to that, but I'd like to get it to work the way it was intended. I've attached the Connection String section as well as the stack trace below. Does anyone have any ideas about how to fix this issue?
<connectionStrings>
<add name="aspnet_staterKits_Test_TimeTracker" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
</connectionStrings>
-Rich[SqlException (0x80131904): An attempt to attach an auto-named database for file C:\WebSites\Test_TimeTracker\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +684979
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +207
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1751
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +32
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +601
System.Data.SqlClient.SqlInternalConnectionTds..ctor(SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +159
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +346
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +445
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +304
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +126
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +226
System.Web.Security.SqlRoleProvider.RoleExists(String roleName) +467
System.Web.Security.Roles.RoleExists(String roleName) +196
ASP.Global_asax.Application_Start(Object sender, EventArgs e) in c:\WebSites\Test_TimeTracker\Global.asax:13
Software Architect
Jacksonville, Florida
Check out my .NET 2.0 Website WebJots (Starter Kit Available)
My Blog - Beta 2 Stuff, ASP.NET, etc.
Rich21
Member
260 Points
52 Posts
Re: An attempt to attach an auto-named database for file ... failed
Apr 22, 2005 08:00 PM|LINK
I figured it out. I took a look at the connection string on the personal web site starter kit which is similar in the way that it connects to the database.
Apparently the Time Tracker Starter kit is missing the following option from its connections string.
"User Instance=True;"
Once I added this option to the Connection String everything works fine. So the new connectionstrings look like this.
<connectionStrings>
<add name="aspnet_staterKits_Test_TimeTracker"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
</connectionStrings>
Software Architect
Jacksonville, Florida
Check out my .NET 2.0 Website WebJots (Starter Kit Available)
My Blog - Beta 2 Stuff, ASP.NET, etc.
sjmac
Member
20 Points
4 Posts
Re: An attempt to attach an auto-named database for file ... failed
May 02, 2005 10:18 PM|LINK
Thanks for that Rich!
That was one of the problems I was having when trying to run the app in my local IIS. After I changed the connection string, I got the same error message again, but this time with a different stack trace.
Then I read your post again, and went to look at my databases with SQL Express Manager, and noticed that aspnetdb was already running in it. I deleted the aspnetdb,, reinstalled blank mdf files for it and the timetracker db, changed the permissions so that "Everybody" had full control to them, and then tested the app. I can now use it!
Can anyone tell me what the user instance=true part of the connection string does?
sjmac
Member
20 Points
4 Posts
Re: An attempt to attach an auto-named database for file ... failed
May 08, 2005 03:22 PM|LINK
User Instance = true is described in this post on the MS news groups:
http://communities.microsoft.com/newsgroups/previewFrame.asp?ICP=sqlserver2005&sLCID=us&sgroupURL=microsoft.private.sqlserver2005.express&sMessageID=%253CuQCkdV5UFHA.2092@CPMSFTNGSA04.privatenews.microsoft.com%253E
Xarain
Member
315 Points
63 Posts
Re: An attempt to attach an auto-named database for file ... failed
Mar 30, 2006 04:26 AM|LINK
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
my User Instance=True is there by default but still get the UNC error thingy.
Timeware
Member
59 Points
21 Posts
Re: An attempt to attach an auto-named database for file ... failed
Sep 15, 2006 08:21 AM|LINK
Hi,
The only times I have received this message have been when, after testing on my local server with it working perfectly, I have moved the application onto a remote test server and placed the application in a subfolder of the remote site.
This always generates this message.
After the data has been moved to the correct location (as it would be on a live server) or the test server location is identified in the web.config file then the problem has been resolved.
In each case the relevant part of the message was "or specified file cannot be opened" as it is being told to look in the wrong location.
Hope this helps you.
porov
Member
249 Points
75 Posts
Re: An attempt to attach an auto-named database for file ... failed
Sep 20, 2006 10:51 PM|LINK
I had the same problem with my website freehosting1.net
What i did to resolve it is to add a 'database' property to my connection string and delete the log file.
But anyway i would like to note that sql server has alot of trouble giving you the right instructions to solve the probems,
i mean the error messages gives u some info about it, but by far not enough to resolve it easily.
Discussion about my forum application I am developing
raikkonen
Member
106 Points
157 Posts
Re: An attempt to attach an auto-named database for file ... failed
Feb 02, 2007 07:40 AM|LINK
I have the same error after a current failure(my pc shat down suddenly)...my connection string is ok and I don;t know what's going wrong...
Any Ideas?
Thanks!!!
Zhao Ji Ma -...
All-Star
23104 Points
2380 Posts
Re: An attempt to attach an auto-named database for file ... failed
Feb 05, 2007 04:14 AM|LINK
Hi, I'm wondering if there is corruption of the aspnetdb.mdf file because of improperly shutting down, Please make sure that the file is still exists under App_Data folder of your web application. If it is, make a copy of it, though it might be corrupt already.
You can try attach your .mdf file with SQL Server. You can try to attach mdf only by using sp_attach_single_file_db too if there is only one ldf file for the db.
If you are using SQL Server instead of SQL Server Express, please back up the last transaction log too.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;253817
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
raikkonen
Member
106 Points
157 Posts
Re: An attempt to attach an auto-named database for file ... failed
Feb 05, 2007 03:24 PM|LINK
Hi,
thanks for the answer but I haven't the file "aspnetdb.mdf " in my application directories...In addition,I use Sql Express Edition and I don't think is possible to attach my database file ...