none
store SqlCommand to a MemoryStream? RRS feed

  • Question

  • Hi,

    I have an assembly which creates SQLCommands and executes them, but now I would like to ship these commands off to another machine using Msmq and have them executed on another machine.  It would be easy if they were straight sql commands to just send the text, but most of them are Stored Procedure calls with many parameters.  Is there anyway I can store a SqlCommand to a MemoryStream so I just use it on the other end?

    Thanks
    • Moved by Stoyko Kostov - MSFT Friday, February 12, 2010 5:36 PM (From:SQL Server Data Access)
    • Edited by daktmacfan Friday, February 19, 2010 6:23 PM spelling error in thread title
    Friday, February 12, 2010 11:34 AM

Answers

  • It sounds like you want to serialize your SqlCommand object and ship it over to another machine to execute - is that right? I think a SqlCommand is tied to a SqlConnection instance, and the SqlConnection is heavily tied to your particular machine. So, I don't think any scheme like that will work for you.

    Moving into the more specific Ado.Net forum in case they have some ideas for how to achieve something like this.
    Friday, February 12, 2010 5:35 PM

All replies

  • It sounds like you want to serialize your SqlCommand object and ship it over to another machine to execute - is that right? I think a SqlCommand is tied to a SqlConnection instance, and the SqlConnection is heavily tied to your particular machine. So, I don't think any scheme like that will work for you.

    Moving into the more specific Ado.Net forum in case they have some ideas for how to achieve something like this.
    Friday, February 12, 2010 5:35 PM
  • Right.

    I was able to store the SQL Command properties relevant to my application in a class and to serialize that.  Then to re-create the SqlCommand from the data in the custom calss once the MemoryStream was deserialized.
    Friday, February 19, 2010 6:27 PM