System.Web.Services.Protocols.SoapException: Server was unable to process request

5.1k Views Asked by At

i am using .net webservice for restoring the database in sqlserver. i am using SQLDMO.dll, to restoring database, when i run the app, i getting the following Error.

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {10021CC1-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80070005. at DBReplicatorService.SQLDEMOScripts..ctor() at DBReplicatorService.DBReplicatorService.RestoreDB(String sDBName, String sUserName, String sPassword, String sBackupFileName)

i am using the code as follows to connect Database

Dim objBCPExport As New SQLDMO.BulkCopy2
Public objDB As SQLDMO.Database2
Dim objServer As New SQLDMO.SQLServer2

Public Function ConnectDatabaseWithRefresh(ByVal sServerName As String, ByVal sDatabaseName As String, ByVal sUserName As String, ByVal sPassword As String) As Boolean
    Dim bResult As Boolean

    Try
        objServer = New SQLDMO.SQLServer2
        objServer.EnableBcp = True
        objServer.Connect(sServerName, sUserName, sPassword)
        objDB = Nothing
        objDB = objServer.Databases.Item(sDatabaseName)
        objDB.DBOption.SelectIntoBulkCopy = True
        bResult = True
    Catch ex As Exception
        bResult = False
    End Try

    Return bResult
End Function

same code when i use in my localhost it is working fine(it contains sql server 2005), and when i use it in hosting server(it contains sql server 2008) i getting the above Error

I getting the error in these variable initialization.

Dim objBCPExport As New SQLDMO.BulkCopy2

and connection string i am using is

     Dim cnnNewDB As New SqlConnection("Data Source=" + pServer + "Initial Catalog="    +   pDatabase + ";Persist Security Info=True;User ID=" + pUserName + ";Password=" + pPassword)

can any one please help me to fix the problem.

Thanks, Senthil.

1

There are 1 best solutions below

0
On

hey, if you're sure about the accuracy of user-server name and password your project may not has right to write the event log.. to fix that go to \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\RestrictGuestAccess and change its value to (0) to reboot