0

如果我在链接服务器上调用过程,我会收到以下错误:

Msg 0, Level 20, State 0, Line 0 当前命令发生严重错误。结果,如果有的话,应该丢弃。

它适用于 SSMS,也适用于经典的 asp,但不在这里。我发现了一些类似的问题,但没有答案。而且我不会(不能)直接连接到链接服务器并在本地执行程序。它必须执行为:myLinkedServer.Database.dbo.myProcedure

任何的想法?

 using (SqlCommand getOutput = new SqlCommand())
        {

            getOutput.CommandText = "myLinkedServer.Database.dbo.myProcedure";
            getOutput.CommandType = CommandType.StoredProcedure;
            getOutput.CommandTimeout = 300;
            getOutput.Connection = conn;

            conn.Open();
            using (SqlDataAdapter da = new SqlDataAdapter(getOutput))
            {
                da.AcceptChangesDuringFill = false;
                da.Fill(exportData);//here error happened
                conn.Close();
                da.Dispose();
4

1 回答 1

0

我找到了一个解决方案:

getOutput.CommandText = "EXEC myLinkedServer.Database.dbo.myProcedure";
getOutput.CommandType = CommandType.Text;

在链接服务器上调用过程时,命令类型应为文本。

于 2013-02-06T10:35:35.333 回答