I wrote an SQL query which has to run on the server. To call that query I am using a VBScript which is stored on the server. When I run that script from the server, the script runs fine. But, when I run the VBScript from my local machine, I get an error stating that access was denied for the SQL script it is calling. I can't seem to figure it out. The following is the VBScript I am using:
dim dbconn, connect, ObjFSO
connect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=DBName;Server=ServerName;Database=DBName;ID=USERID;Password=PASSWORD"
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set dbconn = CreateObject("ADODB.Connection")
dbconn.Open connect
dbconn.execute ObjFSO.OpenTextFile("\\ServerName\FolderPath\FileName.sql").ReadAll,128
Set dbconn = Nothing
The error I get is:
Note: I do not get the error message seen in the image above, when I run the same VBScript from the server.
Is there a way to get this program to only run from the server where it is stored?
Am I just missing something really simple?