By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

Can't Serialize SqlConnection

P: n/a
I have a class that I created that requires me to serialize it for
specific reasons. I have an SqlConnection that is a private member of
the class, and therfore the serialization fails. The SqlConnection
must be private as it is shared by many sub routines within the class.
How do I get around this? Is it possible to serialize the
SqlConnection Class?

Thanks for your help in advance!

Andrew Alford
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I don't think you can get around it. The SqlConnection class is not
serializable (understandably), so there is really not much you can do if you
class has that as a member.

Maybe you can keep the connection string as a member, which would be
serializable.

"Andrew Alford" <An**********@intersomnia.net> wrote in message
news:ad**************************@posting.google.c om...
I have a class that I created that requires me to serialize it for
specific reasons. I have an SqlConnection that is a private member of
the class, and therfore the serialization fails. The SqlConnection
must be private as it is shared by many sub routines within the class.
How do I get around this? Is it possible to serialize the
SqlConnection Class?

Thanks for your help in advance!

Andrew Alford

Nov 20 '05 #2

P: n/a
> I don't think you can get around it. The SqlConnection class is not
serializable (understandably), so there is really not much you can do if you class has that as a member.

Maybe you can keep the connection string as a member, which would be
serializable.

Yes greath serializing the connection string

:-)

Cor
Nov 20 '05 #3

P: n/a
Heh, well, it's the next best thing.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uR*****************@TK2MSFTNGP10.phx.gbl...
I don't think you can get around it. The SqlConnection class is not
serializable (understandably), so there is really not much you can do if

you
class has that as a member.

Maybe you can keep the connection string as a member, which would be
serializable.

Yes greath serializing the connection string

:-)

Cor

Nov 20 '05 #4

P: n/a
You could mark the private member with the NonSerializedAttribute so that
the rest of the class could be serialized.

HTH,
Greg
"Marina" <so*****@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I don't think you can get around it. The SqlConnection class is not
serializable (understandably), so there is really not much you can do if you class has that as a member.

Maybe you can keep the connection string as a member, which would be
serializable.

"Andrew Alford" <An**********@intersomnia.net> wrote in message
news:ad**************************@posting.google.c om...
I have a class that I created that requires me to serialize it for
specific reasons. I have an SqlConnection that is a private member of
the class, and therfore the serialization fails. The SqlConnection
must be private as it is shared by many sub routines within the class.
How do I get around this? Is it possible to serialize the
SqlConnection Class?

Thanks for your help in advance!

Andrew Alford


Nov 20 '05 #5

P: n/a
Excellent! This solves my problem completely. I'd only thought about
serialization in the context of defining the class - rather than during
dimensioning.

Thanks to all for your help

Andrew Alford
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.