Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL connectionstring
Unable to open the physical file "D:\_Web3rev\App_Data\dbStudent.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
An attempt to attach an auto-named database for file D:\_Web3rev\App_Data\dbStudent.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
 

i am receiving this error on my localhost everytime i accessing the local db for username and password. i have another authentication which is windows authentication for users in our intranet. i am using sql express for other users to access their data but create an error in my connection string. i tried a number of connection string but i failed.
 
can somebody share me his thought about this?
 
this is my connection string in web.config:
 
<add name="myDbConnectionString1" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|database.mdf" providerName="System.Data.SqlClient"/>
 
help will be more appreciated Smile | :)
Posted 30-Oct-12 20:45pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I am using DefaultAppPool application pool in my local IIS and the identity is NETWORK SERVICE. I tried creating another instance of login in another directory and it works but in this instance it failed and receiving the above error message. my windows authentication has nothing to do with this coz i tried removing it in my web.config and still the same error appears.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Can somebody share his comment about my topic? its a connection string to my sql database. i can explain further.
 

this is the true error that apppears:
 
[SqlException (0x80131904): Unable to open the physical file "D:\_Web3rev\App_Data\database.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
An attempt to attach an auto-named database for file D:\_Web3rev\App_Data\dbStudent.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) +6256377
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1099
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +248
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +6271242
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6271208
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +354
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +703
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +54
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6272472
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +81
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1657
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +88
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6275911
   System.Data.SqlClient.SqlConnection.Open() +258
   System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +53
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +188
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +573
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +161
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +2790918
   System.Web.UI.WebControls.SqlDataSource.Select(DataSourceSelectArguments arguments) +31
   WebGrades.log_Click(Object sender, EventArgs e) in d:\_Web3rev\WebGrades.aspx.cs:31
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

further:
 
Line 29:         sds.SelectCommand = "SELECT * FROM [myTable] WHERE [username] = @username AND [password] = @password";
Line 30: 
Line 31:         DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty); -->> this is the error
Line 32:         try
Line 33:         {
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

after doing some changes in my IIS this is the error:
 
Cannot open user default database. Login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100