简体   繁体   English

如何从 SSIS package 中 ping?

[英]How to ping from within an SSIS package?

I'm trying to verify a connection through a firewall, and we are very limited in the access allowed.我正在尝试通过防火墙验证连接,但我们的访问权限非常有限。 Ultimately, data will be loaded from an Access database on another server to our SQL Server database using an SSIS package.最终,数据将使用 SSIS package 从另一台服务器上的 Access 数据库加载到我们的 SQL 服务器数据库。 I can ping that source server from my computer and get a reply -- I want to put that in our SSIS package and see if the destination SQL Server can get a ping reponse.我可以从我的计算机 ping 那个源服务器并得到一个回复——我想把它放在我们的 SSIS package 中,看看目标 SQL 服务器是否可以得到一个 ping 响应。

Right now, the OLE DB source connection fails from both my computer and the server, ping works directly from my computer, and I don't know if it will work from the server or not.现在,我的计算机和服务器的 OLE DB 源连接都失败了,ping 直接从我的计算机工作,我不知道它是否可以从服务器工作。 SSIS is the only thing I can put and run on the server, and it also what we plan on using for getting data from this other source. SSIS 是我唯一可以在服务器上放置和运行的东西,它也是我们计划用来从其他来源获取数据的东西。

Is there a fairly simple way to use a SSIS package to ping a specific address?有没有一种相当简单的方法可以使用 SSIS package ping 特定地址? I probably don't even need to know anything more than whether it fails or works.我可能什至不需要知道它是否失败或有效。

I cannot use sys.sp_comdshell because that is turned off as part of our security configuration for our sql server.我不能使用 sys.sp_comdshell,因为它在 sql 服务器的安全配置中被关闭。 I cannot remote to the server and use ping directly.我无法远程访问服务器并直接使用 ping。

You could add a Script Task to your Control Flow with some code that does the ping for you.您可以使用一些为您执行 ping 操作的代码将脚本任务添加到您的控制流中。 The System.Net.NetworkInformation namespace in .NET 2.0 and up contains a Ping class that can do the work for you. .NET 2.0 及更高版本中的System.Net.NetworkInformation命名空间包含可以为您完成工作的Ping class。 I suspect it might look something like this:我怀疑它可能看起来像这样:

public void Main()
{
    using (Ping ping = new Ping())
    {
        try
        {
            PingReply reply = ping.Send(url, 100);
            if (reply.Status == IPStatus.Success)
            {
                Dts.TaskResult = (int)ScriptResults.Success;
            }
            else
            {
                Dts.TaskResult = (int)ScriptResults.Failure;
            }
        }
        catch
        {
            Dts.TaskResult = (int)ScriptResults.Failure;
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM