If I call procedure on linked server, I get the following error:
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
It works in SSMS, also it works with classic asp, but not here. I have found some similar questions, but no answer. And I wont(can’t) connect directly to linked server and execute procedure locally. It must be executed as : myLinkedServer.Database.dbo.myProcedure
Any idea?
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();
I have found a solution:
When calling a procedure on linked server, command type should be as text.