【发布时间】:2023-03-17 03:21:01
【问题描述】:
在我的应用程序中,我正在将数据读取到数据库,然后我想启动集成服务将数据导入多维数据集。这是我用来从 SSMS 启动它的命令:
execute master..xp_cmdshell 'dtexec /DTS "\MSDB\B_Costs" /SERVER . /CHECKPOINTING OFF /REPORTING V'
但是如何从我的应用程序中使用它?我在开始时遇到此错误:
对象“xp_cmdshell”、数据库“mssqlsystemresource”、架构“sys”的执行权限被拒绝。
使用这样的命令后:
GRANT EXECUTE ON xp_cmdshell TO [IIS APPPOOL\DefaultAppPool]
我遇到另一个错误:
xp_cmdshell 代理帐户信息无法检索或无效。验证“##xp_cmdshell_proxy_account##”凭据是否存在并包含有效信息。
当我检查时,我在 Database Engine -> Security -> Credentials 中没有凭据。
我想使用这样的命令:
EXEC sp_xp_cmdshell_proxy_account 'IIS APPPOOL\DefaultAppPool', 'password'
但我不知道我应该在“密码”中写什么。有什么建议吗?
这是我的 CubeController:
public ActionResult Index()
{
string sql = "execute master..xp_cmdshell 'dtexec /DTS \"\\MSDB\\B_Costs\" /SERVER . /CHECKPOINTING OFF /REPORTING V'";
try
{
MyEntity.Database.ExecuteSqlCommand(sql);
}
catch (Exception e)
{
string error = "There was an error: <br />" + e.Message;
TempData["Message"] = error;
}
return RedirectToAction("Index","Home");
}
【问题讨论】:
标签: asp.net tsql xp-cmdshell