Dynamic IP/Database Access Problem

Last post 09-17-2007 10:20 AM by mank1327. 3 replies.

Sort Posts:

  • Dynamic IP/Database Access Problem

    09-16-2007, 2:58 AM
    • Loading...
    • mank1327
    • Joined on 11-16-2006, 6:14 PM
    • Posts 24

    I think the problem is similar to the publishing problems some experience when moving out of the localhost testing environment.

    I can access the database if I run the built-in debugger/server in VWD, but when I switch to the 'live' server (my own machine through DynDNS running IIS 5.1) the database can't be accessed because VWD is using it. Something like that.

    Here's the well-known error:

    [SqlException (0x80131904): Unable to open the physical file "c:\inetpub\wwwroot\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 c:\inetpub\wwwroot\App_Data\Database.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) +734979
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
    System.Data.SqlClient.SqlConnection.Open() +111
    System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
    System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
    System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
    System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
    System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
    System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
    System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
    System.Web.UI.WebControls.GridView.DataBind() +4
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
    System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
    System.Web.UI.Control.EnsureChildControls() +87
    System.Web.UI.Control.PreRenderRecursiveInternal() +41
    System.Web.UI.Control.PreRenderRecursiveInternal() +161
    System.Web.UI.Control.PreRenderRecursiveInternal() +161
    System.Web.UI.Control.PreRenderRecursiveInternal() +161
    System.Web.UI.Control.PreRenderRecursiveInternal() +161
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
    I want to start at the installation of VWD and SQL Server Express to determine what information needs to be supplied so that the app can be accessed through an http:// address, whether it's a dynamic IP or a separate machine with a static IP. I'm guessing that the two scenarios are similar.

    Running PHP apps on *AMP works when Apache, MySQL, and PHP all recognize www:data/www:data as a valid user/password, and my logic (possibly flawed) tells me a similar configuration should be possible with IIS/SQL/C#. However, I'm not familiar enough with the Windows environment to determine a correlation.

    I'm logged into the XP machine as the single user/administrator.

    Environment: DynDNS, XP Pro SP2, VWD/SQL Express, .Net Frameworks 1, 2, and 3. SQL Server Management Express. And the database is one I created/attached in VWD.

    Is it better to create a system database through SQL Server Management Express for this? If so, what is a workable set of permissions to allow anyone other than myself to access the app through http:// (not localhost)?

    IIS does serve aspx as standard html. It's only when the data access is involved that the error gets thrown.

    I've researched MSDN and asp.net for solutions, but the suggestions are generally complicated, ineffective, and vague. It would be a great help to developers to work out an ordered procedure for installation, configuration, testing, and deployment to achieve predictable results.

    I believe this can be worked out for everyone's benefit.

    Thanks for reading.

    Mark 

    Dell 2400, XP SP2, IIS 5.1, VWD/SQL 2005 Express
    Filed under: , ,
  • Re: Dynamic IP/Database Access Problem

    09-16-2007, 4:29 AM
    Answer
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,117

    Please check the permissions on the directory  c:\inetpub\wwwroot\App_Data\. The account IIS is running on (proably ASPNET) will need at least R/W and probably full control to access the database. You can find out the account by going to:

    1.  Start, Control Panel, Administrative Tools, Internet Information services
    2. Navigate to the site, right click on the site node and select properties.
    3. Click the "directory security" tab
    4. Click the top edit button
    5. If the anonymous access is checked, IIS will use that account shown in the textbox alongside.
    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Dynamic IP/Database Access Problem

    09-17-2007, 1:41 AM
    • Loading...
    • mank1327
    • Joined on 11-16-2006, 6:14 PM
    • Posts 24

    Thanks. That did it.

    I checked read and write on the App_Data folder by right clicking it while in Internet Information Services and choosing properties to get to the permissions.

    The anonymous access was already checked and I left the default settings for user and password, along with allow IIS to control password remaining checked.

    Restarted IIS, closed VWD, and navigated to the url. All good. Data is displayed in GridView.

    It came with a price, though. Now I can't work with the database from within VWD. Attempting to connect to it prompted me to create a new connection, which I did. I don't know what happened to the old one. Now the same error is displayed in a common dialog box.

    I'll try a system database instead of an attached one. The app isn't being moved anywhere, so that may be the better route to take.

    I marked your response as the answer because it did get the result I asked for. I'll run some tests and start a new thread if I can't work it out.

    Thanks again, M 

    Dell 2400, XP SP2, IIS 5.1, VWD/SQL 2005 Express
    Filed under: , ,
  • Re: Dynamic IP/Database Access Problem

    09-17-2007, 10:20 AM
    • Loading...
    • mank1327
    • Joined on 11-16-2006, 6:14 PM
    • Posts 24

    One more addition.

    Using an attached database created in VWD (not a system database which presented it's own set of unique problems) I was able to get to the page served by IIS through my URL after following the instructions outlined above by Tatworth.

    But when I tried editing the test entry using the GridView I got this error:

    "Failed to update database because the database is read-only."

    To fix this part I followed these instructions posted by a user on the MSDN forums and it worked.

    "failed to update database" because it is "read only".
    i also have the same problem, and i have done with it.
    microsoft explanation was using "sseutil.exe", which is not help at all.
    actually it just a matter of security.
    try this steps, to solving that message.

    Step 1:

    Open My Computer from the desktop, and from the Tools menu select Folder Options.

    Click on the View tab, and scroll to the end of the Advanced Settings box.
    Near the bottom, you will find an entry named "Use simple file sharing (recommended)".

    Uncheck this box, and click the OK button.

    Now when you right-click on a file or folder and select Properties, you will see the Security tab.

    Step 2:

    On a computer running Windows XP Professional, you just need to grant the ASPNET account permissions.

    Use Windows Explorer to browse to the root folder of your Personal Website.

    Right click on the folder and choose properties. Then click on the Security Tab.

    Click the Add button, the Advanced button, and then the Find Now button.

    Then click on the ASPNET item in the list and click Ok, and Ok again.

    Then click the Allow Modify checkbox and click Ok.

    You can follow the same steps for the Network Service account.

    i hope this can answer everyone problem about this message.

    Best regards,

    ice
    (looking for H1B Visa to work in USA)
    kiong_hari at hotmail dot com

    Source: http://forums.microsoft.com/msdn/showpost.aspx?postid=68698&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=2 

    *

    Now the information is displayed and can be edited and updated without problems. The database can be worked with from within VWD, but you'll have to close the connection to it before going back to the page using it. Otherwise you'll get the first error described in this thread. You'll also want to restart IIS so the new permissions take effect.

    Dell 2400, XP SP2, IIS 5.1, VWD/SQL 2005 Express
    Filed under: , ,
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter