Error occured while uploading .mdf .ldf file to hosting server. RRS feed

  • Question

  • User-199788946 posted

    ERROR message:

    System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: To use ALTER DATABASE, the database must be in a writable state in which a checkpoint can be executed. To use ALTER DATABASE, the database must be in a writable state in which a checkpoint can be executed. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DZWebSvc.DZWebAgent.AttachNewUserDB(String DBName, String LoginName, String OriginalDBFileName, String OriginalLogFileName, String NewDBFileName, String NewLogFileName, Int32 MaxDataFileSizeMB, Int32 MaxLogFileSizeMB, String ConnectionString, Boolean ChangeDefaultSchemaToDbo, String tk) in C:\Projects\Doka2019\DZWebSvc\DZWebAgent.asmx.cs:line 2167 --- End of inner exception stack trace ---

    Monday, April 27, 2020 5:01 AM

All replies

  • User1120430333 posted

    To me, this seems that you should be discussing this with the hosting provider.

    Monday, April 27, 2020 5:49 AM
  • User932909087 posted

    Hi James.

    You need to upload full .bak file to hosting server, you can't upload .mdf and .ldf, you are unable to restore it. You need to conver it to .bak file. You can run this script:

    BACKUP DATABASE [NameOfDatabase] TO  DISK = N'D:\path\filename.bak' WITH NOFORMAT, NOINIT,  NAME = N'NameOfDatabase-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10

    Monday, April 27, 2020 7:05 AM
  • User-474980206 posted

    Probably the Sqlserver process account trying to do the attach, only has read access to the files. 

    Monday, April 27, 2020 2:50 PM
  • User753101303 posted


    I would avoid this. MDF and LDF Files are the files on which SQL Server works and this is the last option I would use (including on premise).

    ilw favor doing a "real" database backup and restoring this backup on a server. Your hosting service should have some documentation about how to move a database on their service (or this is a server on which you have full control ?)

    Edit: or you wrote your own service to try to update the server side db ???

    Monday, April 27, 2020 3:09 PM