I am trying to use OLE automation to get the last modified date of a file located in a mapped drive on the SQL Server computer. The network is peer-to-peer. I logged on the SQL server as the administrator. The SQL Server and the workstation sharing its folder have the same password for the administrator account.
When I run the following code, I can not get the file object. The error output contains only nulls. The variable @FilePath1 contains full network path like "\\jack\sharedfolder\test.bak".
I know the code has no error since it worked for another network path, which points to a file on a network storage device's public folder.
I ran a vbscript on the SQL server and was able to get the file object.
I do not know where went wrong. As I understand, in a peer-to-peer network, if two computers have the same user name and password, then a user from one computer should be able to access another computer without problems.
Here is my code:
Any suggestions?
When I run the following code, I can not get the file object. The error output contains only nulls. The variable @FilePath1 contains full network path like "\\jack\sharedfolder\test.bak".
I know the code has no error since it worked for another network path, which points to a file on a network storage device's public folder.
I ran a vbscript on the SQL server and was able to get the file object.
I do not know where went wrong. As I understand, in a peer-to-peer network, if two computers have the same user name and password, then a user from one computer should be able to access another computer without problems.
Here is my code:
Code:
EXEC @hr=sp_OACreate 'Scripting.FileSystemObject', @objFSys out
-- get file
EXEC @hr=sp_OAMethod @objFSys, 'GetFile', @obj out, @FilePath1; -- step 200
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo null, @ErrSrc OUT, @ErrDesc OUT
select @msg=@msg + char(10) + 'Step 200: ' + char(10) +
'Err Source: ' + coalesce(@ErrSrc,'') + char(10) +
'Err Description: ' + coalesce(@ErrDesc,'')
END
Any suggestions?