Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调用链接服务器过程_C#_Sqlcommand - Fatal编程技术网

C# 调用链接服务器过程

C# 调用链接服务器过程,c#,sqlcommand,C#,Sqlcommand,如果在链接服务器上调用过程,则会出现以下错误: 消息0,级别20,状态0,第0行 当前命令发生严重错误。如果有结果,则应放弃 它适用于SSMS,也适用于经典asp,但不适用于这里。我发现了一些类似的问题,但没有答案。我不会(不能)直接连接到链接的服务器并在本地执行该过程。它必须作为:myLinkedServer.Database.dbo.myProcedure执行 有什么想法吗 using (SqlCommand getOutput = new SqlCommand()) {

如果在链接服务器上调用过程,则会出现以下错误:

消息0,级别20,状态0,第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();

我找到了一个解决方案:

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

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

如果此答案是解决方案,请将其标记为解决方案。