Serialization question


Just a question : does somebody knows if it's possible to serialize an sql connection ?
And how ?

 

5 Comments

  • Why would you want to?

  • I have a class with anew constructor to a sql connection.





    I would like to see if I can store in a statebag the object to avoid calling the object everytime I need it in my code.





    Maybe I'm wrong ... or stupid, but the sqlConnection seems to be not serializable.





    For the moment I call my object evrytime, but just to see if I can improve a bit the performances ;-)

  • sql connection is not serializd because it makes no sense. a connection is not a cheap resource, you might want to pass the connection string itself and open it when ever you want. it seems you have a design problem if you need to solve such a thing.

  • OK guys your're right I was wrong. Thanks ;-)

  • It's sort of hard to serialize an active network connection now isn't it :)


    (and at the end of the day that is what an SqlConnection is!)





    Generally, MarshalByRef objects don't serialize :)

Comments have been disabled for this content.