Getting 0x800C0005 System error in SQL Server - sql

The following code is used to call a web service from SQL Server:
Declare #Object as Int;
Declare #ResponseText as VARCHAR(MAX);
Exec sp_OACreate 'MSXML2.XMLHTTP', #Object OUT;
Exec sp_OAMethod #Object, 'open', NULL, 'GET','http://localhost/Service1.asmx/HelloWorld?name=xyz', false;
Exec sp_OAMethod #Object, 'send';
EXEC sp_OAGetErrorInfo #Object
Create table #tmp(dt varchar(max))
insert into #tmp
exec sp_OAGetProperty #Object, 'ResponseText' --,#strLine OUtPUT
Select dt from #tmp -- single column/single row.
Drop Table #tmp -- clean up
Exec sp_OADestroy #Object;
But I am getting below error:
0x800C0005 msxml3.dll System error: -2146697211
Any pointers ...?

There are two (2) ways to fix Msxml3 Dll 0x800c0005 System Error Error:
Advanced Computer User Solution (manual update):
1) Start your computer and log on as an administrator.
2) Click the Start button then select All Programs, Accessories, System Tools, and then click System Restore.
3) In the new window, select "Restore my computer to an earlier time" option and then click Next.
4) Select the most recent system restore point from the "On this list, click a restore point" list, and then click Next.
5) Click Next on the confirmation window.
6) Restarts the computer when the restoration is finished.
Novice Computer User Solution (completely automated):
1) Download (Msxml3 Dll 0x800c0005 System Error) repair utility.
2) Install program and click Scan button.
3) Click the Fix Errors button when scan is completed.
4) Restart your computer.
More details

Related

Move text file from one folder to another folder using sql script

I have been using the following sql script to move file from one location to another .
EXEC
master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE
EXEC
master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE
DECLARE #cmd nvarchar(500), #folderName varchar(100),#move varchar(100),#destinationpath varchar(50)
SET #folderName = 'Newfolder_' + REPLACE(CONVERT(varchar(10), GETDATE(), 101), '/', '')
SET #cmd = 'mkdir C:\FileDestination\' + #folderName
EXEC master..xp_cmdshell #cmd --- this will create folder(newfolder_mmddyyy)
set #destinationpath='C:\FileDestination\'+#folderName
set #move ='move c:\filesource\* '+ #destinationpath
exec master.dbo.xp_cmdshell #move ---this will move files to newly created folder
But it's showing the error as follows
The system cannot find the file specified.
Can any one let me know the solution for this. Thanks Alot for your help !
If "filesource" and "FileDestination" are example folder locations, then it could be that the variable for the move command is too small. Try making it the same as #cmd, i.e. #move nvarchar(500)
It seems to be the access issue on the filesource folder, try giving full access to everyone on the folder.
I tried the exact code on my system and it works fine for me (moved test file).

SQL Image Extraction

I'm trying to extract images from a restored database. The script below ostensibly runs fine: meaning it extracts the images and saves the number of files I expect to see (and the size I would expect to see) into a network folder as .pdf files. However, when I try to open the files this is the error message I receive:
Adobe Reader could not open 'filename.pdf' because it is either not a supported file type or because the file
has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
I have run this script before in other environments (2 to be exact) and it's worked fine.
I have verified that the actual images are good. You can access the files via the front end.
It doesn't appear that the values are encrypted. Although I'm not completely sure.
The Data Type natively is: image
I've been using SQL for a while but would consider myself a noob, whereas, I'm basically self-taught -so please go easy.
Any guidance / suggestions / insight will be very much welcome.
Thank you.
--========================================================================
USE <<ENTER_DATABASENAME>>
GO
sp_configure 'show advanced options', 1
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1
GO
RECONFIGURE
GO
DECLARE #FILEID VARCHAR(12),
#IMAGE VARBINARY(MAX),
#OBJSTREAM INT,
#FILENAME VARCHAR(MAX),
#BASEDIR VARCHAR(MAX)
SET #BASEDIR = '<<ENTER_NETWORKPATH>>'
PRINT 'BASEDIR: ' + #BASEDIR
DECLARE IMGEXTRACT CURSOR FAST_FORWARD FOR
select <<ENTER_COLUMNNAME01>>, <<ENTER_COLUMNNAME02>>
from <<ENTER_TABLENAME>>
OPEN IMGEXTRACT
FETCH NEXT FROM IMGEXTRACT INTO #FILEID, #IMAGE
WHILE ##FETCH_STATUS = 0
BEGIN
SET #FILENAME = #BASEDIR + '\' + #FILEID + '.pdf'
PRINT #FILENAME
EXEC sp_OACreate 'ADODB.Stream', #OBJSTREAM OUTPUT
EXEC sp_OASetProperty #OBJSTREAM, 'Type', 1
EXEC sp_OAMethod #OBJSTREAM, 'Open'
EXEC sp_OAMethod #OBJSTREAM, 'Write', NULL, #IMAGE
EXEC sp_OAMethod #OBJSTREAM, 'SaveToFile', NULL, #FILENAME, 2
EXEC sp_OAMethod #OBJSTREAM, 'Close'
EXEC sp_OADestroy #OBJSTREAM
FETCH NEXT FROM IMGEXTRACT INTO #FILEID, #IMAGE
END
CLOSE IMGEXTRACT
DEALLOCATE IMGEXTRACT
GO
--========================================================================

Exec master..xp_cmdshell 'Del...' is not working

I'm trying to delete a excel file using xp_cmdshell, but is not working... I check the other questions of here but I can't solve my issue, I activated the advanced options of SQL SERVER to allow this sintax, but it show's me a error message like this:
No se encuentra C:\xampp\htdocs\Web_Seguimiento\Body\Upload\Files\Carga
No se encuentra C:\WINDOWS\system32\Masiva
NULL
My code:
---- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
declare #sqlquery varchar(255)
declare #name varchar(255)
set #name = 'Carga Masiva Usuarios General.xlsx'
set #sqlquery= 'Del C:\xampp\htdocs\Web_Seguimiento\Body\Upload\Files\'+#name +''
exec master..xp_cmdshell #sqlquery
Can anybody tell me what I do wrong, or how can I solve this issue...???
Try putting quotes around the file name, like this:
set #sqlquery= 'Del "C:\xampp\htdocs\Web_Seguimiento\Body\Upload\Files\'+#name +'"'

How to close command prompt window triggered by xp_cmdshell

In our stage environment ,we want run exe automatically based on errors .Below is the code i am using
declare #minid int
declare #maxid int
select #minid=min(sno) from activityid
select #maxid =max(sno) from activityid
declare #cmd varchar(8000)
declare #cmd2 varchar(8000)
set #cmd='E:\Debug\Debug\Acces.exe /ly /activityId '
declare #ad int
declare #cmd1 varchar(8000)
while #minid<=#maxid
begin
select #ad=ad from activityid where sno=#minid--get activity
set #cmd2=#cmd+cast(#ad as varchar(8000))
exec master.dbo.xp_cmdshell #cmd2
set #minid=#minid+1
end
So everytime in loop ,a new exe is being triggered.
How can i close the exe after execution, irrespective of success or failure .
Please note that this i have to do from sql only to send emails and this is stage,so we need not bother about xp_cmdshell disadvantages.
To answer your question, you really can't close the exe... that's up to the exe to do, unless you KILL it or something. If you're going to run an executable like this from a command shell, you have to make sure it behaves in the manner you need it to. You're basically at the mercy of the executable until it finishes and exits.

Unable to delete zip files from DB server location using xp_cmdshell

I have a Zip file created and I am unable to delete it using the below command.
xp_cmdshell 'rm "F:\EXIS\Reports\Individual.zip"'
It gives an error saying File not found, when I can actually see the file.
I tried using xp_cmdshell 'del "F:\EXIS\Reports\Individual.zip"'
But, this asks for a confirmation, which I actually cannot input.
Please suggest if anything,
Thanks.
The message is more generic in the sense the file is not found with the current credentials of SQL Server process while accessing the indicated location.
I suspect it is a problem of rights, so please assure the SQL Server proecess has rights to delete file in that location. An alternative suggestion is to perform a "dir" on that location.
Try executing delin silent mode like:
xp_cmdshell 'del /Q "F:\EXIS\Reports\Individual.zip"'
And also: if SQL Server is running on a different machine the path must of course be valid for that machine.
--change server configuration like :
--Script to enable the XP_CMDSHELL
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1 GO
-- To update the currently configured value for advanced options.
RECONFIGURE GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1 GO
-- To update the currently configured value for this feature.
RECONFIGURE GO;
DECLARE #BackUpPath varchar(255) ,#sqlQuery varchar(255)
Set #BackUpPath='D:\All DB BackUp\TestDB.bak'
IF dbo.fn_FileExists(#BackUpPath)=1
BEGIN
SET #sqlQuery='DEL /Q "' + #BackUpPath + '"';
PRINT #sqlQuery
EXEC master..xp_cmdshell #sqlQuery
IF dbo.fn_FileExists(#BackUpPath)=0
BEGIN
PRINT 'File Deleted'
END
ELSE
BEGIN
PRINT 'File not Deleted'
END
END
IF #BackUpPath contains space , you must type your path like "your
path"