Passing an SqlClient Command as a function argument (between two services)

  • Thread starter Thread starter Niki Reid via .NET 247
  • Start date Start date
N

Niki Reid via .NET 247

I'm trying to set up a web service that provides generic services to our other web services (resident on the same physical machine).

I've discovered that sqlCommands aren't serialisable, and that I need to pass an object reference.

Can anyone please give me either assistance in using object refs, or point me to a suitable resource?
I've found the general MS documentation on it, but can't find any eaxmples of what I need to do.

For example, I had intended the following, but now know this won't work.

AS GENERAL SERVICE
public main_service_fn() as dataset

'create sqlCommand COMM
'set COMMs attributes
'create dataset DS
DS = generic_server_fn(COMM)
end function

AS SERVICE TO SERVICE
public function generic_server_fn(byref COMM AS sqlclient.sqlcommand) as dataset
'create data adaptor DA
'set DA command property to COMM passed in
'create dataset, fill it using DA and return it.

The alternative is to TOSTRING the command and create a parsing routine on the generic server.
What would you recommend?

Many thanks for any assistance.

Niki
 
Hi,

Web Services do not have the capability to handle object references. By
their nature, everything is sent into an XML message and recreated on the
other side. Any appearance to actually pass an object reference is just some
clever code :).

I suggest you manually serialize the parts of the SqlCommand that you
need (CommandText, Parameters?) and send those instead.

-mike
MVP
 
Back
Top