Re: Passing Parameters through a linked server?

From: Sahil Malik (contactmethrumyblog_at_nospam.com)
Date: 10/21/04


Date: Thu, 21 Oct 2004 01:58:37 -0400

Are you able to execute this without linked servers in picture?

- Sahil Malik
You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik

"Adam Smith" <adam2001usa@hotmail.com> wrote in message
news:%231wCdwutEHA.1464@TK2MSFTNGP15.phx.gbl...
> Hello I have a stored proc:
>
> CREATE PROCEDURE dbo.sp_test
> @IN int,
> @ID int OUTPUT
> AS
> begin
> SET NOCOUNT ON
>
> Set @ID=12345 + @IN
> end
>
> GO
>
> I'm executing this through a linked server. The exception returned is:
>
> Could not execute procedure 'sp_test' on remote server
> 'QAPS2Remote'.\r\n[OLE/DB provider returned message: Parameter type
> cannot be determined for at least one variant parameter.]
>
> The literal query being run is:
>
> declare @P1 int
> set @P1=NULL
> exec QAPS2Remote.HRXMLCollector_prod.dbo.sp_test @IN = 1, @ID = @P1
> output
> select @P1
>
> How do I declare the parameters using C#? The code I'm using is:
>
> dbCommand.Connection = conn;
> dbCommand.CommandType = CommandType.StoredProcedure;
>
> dbCommand.CommandText = "QAPS2Remote.HRXMLCollector_prod.dbo.sp_test";
>
> SqlParameter sqlParameterIn = dbCommand.Parameters.Add("@IN",
> SqlDbType.Int);
>
> sqlParameterIn.Direction = ParameterDirection.Input;
> sqlParameterIn.Value = 1;
> SqlParameter sqlParameterOut =
> dbCommand.Parameters.Add("@ID",SqlDbType.Int);
> sqlParameterOut.Direction = ParameterDirection.Output;
>
> dbCommand.ExecuteNonQuery();
>
> Thanks in advance.
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • executinga sp using linked server gives an error
    ... Linked servers are connected using following syntax.. ... EXECUTE.databasename.dba.PickupWeight_SP ... >BEGIN DISTRIBUTED TRANSACTION ...
    (microsoft.public.sqlserver.programming)
  • login failed for user "null"
    ... I have problem with linked servers (MS SQL Server 2k)- when I try to execute ... Network Protocols is TCP/IP. ...
    (microsoft.public.sqlserver.security)
  • RE: Linked Server setups
    ... Execute sp_linkedservers. ... This will give you all the details you want about the linked servers. ... Regards ... Deepak ...
    (microsoft.public.sqlserver.programming)
  • Re: [patch 1/7] Immediate Values - Architecture Independent Code
    ... static unsigned int stopmachine_num_threads; ... * help our sisters onto their CPUs. ... all the other CPUs will execute the callback concurrently. ...
    (Linux-Kernel)
  • Re: Marking a Page of Memory Executable
    ... What I want to do is get an executable and writable page of memory, ... instruction pointer on x86) to that page so that it will execute that ... mmap, munmap - map or unmap files or devices into memory ... void * mmap(void *start, size_t length, int prot, int ...
    (comp.lang.c)