我怎样才能sqlcmd.exe从ASP页运行? [英] How can I run sqlcmd.exe from an ASP page?

查看:162
本文介绍了我怎样才能sqlcmd.exe从ASP页运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我们的数据库版本控制(和自动安装)过程的一部分,我们必须对各种.sql文件能够运行sqlcmd.exe从ASP页面中。在code我使用要做到这一点:

As part of our database revision control (and auto-installation) procedures we need to be able run sqlcmd.exe on various .sql files from within an ASP page. The code I'm using to do this is:

Dim cmd : cmd = "sqlcmd -S " & DATABASE_SERVER & " -U " & DATABASE_UID & " -P " & DATABASE_PWD & " -d " & DATABASE_NAME & " -i """ & scriptPath & """ -b"
Dim wshShell : Set wshShell = Server.CreateObject("WScript.Shell")
Dim return : return = wshShell.Run(cmd, 0, True)

我有code工作我的开发机(运行XP)上,但现在我已经部署到它有问题我们的Windows 2003服务器。是,对于返回值的问题总是1.这也发生,如果我设法得到它运行一个批处理文件或其他任何我能想到的(如果我对CMD的值更改为一个不存在的文件时,它弹了如我期望)

I have the code working on my development machine (running XP) but now that I've deployed it to our Windows 2003 server it's having problems. The problem being that the value for return is always 1. This also happens if I try to get it to run a batch file or anything else I can think of (if I change the value for cmd to an non-existing file it bombs out as I'd expect)

我已经尝试添加I_USR和I_WAM有执行上都sqlcmd.exe和cmd.exe的权限,但它仍然返回1。如果我在服务器上打开一个命令提示符并做了的runas / user:用户服务器名称\\ i_usr sqlcmd.exe工作正常,但是从ASP网页运行仍然不能正常工作。

I've tried adding I_USR and I_WAM to have execute permissions on both sqlcmd.exe and cmd.exe but it still returns 1. If I open a command prompt at the server and do a "runas /user:servername\i_usr sqlcmd.exe" that works fine but running from the ASP page still doesn't work.

此外,在运行.SQL脚本时手动一切顺利,所以没有问题,和他们在一起。

Also, when running the .sql scripts manually everything runs smoothly so there's no problem with them.

有没有,我已经忘了IIS或Windows一般内更改服务器上的任何安全设置,使其工作?

Are there any security settings on the server that I've forgotten to change within IIS or Windows generally to make it work?

在此先感谢互联网。

推荐答案

这个问题是通过改变第一行来解决:

The problem was solved by changing the first line to:

Dim cmd : cmd = "%COMSPEC% /C sqlcmd -S " & DATABASE_SERVER & " -U " & DATABASE_UID & " -P " & DATABASE_PWD & " -d " & DATABASE_NAME & " -i """ & scriptPath & """ -b"

这篇关于我怎样才能sqlcmd.exe从ASP页运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆