473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Can't Serialize SqlConnection

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
5 3535
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
> 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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joakim | last post by:
Hi, I would like to serialize UI components for local storage in a file. Can this be done with for example a Button? /Joakim
1
by: Michael | last post by:
Hi I anyone have a clue or can solve my problem I would be glad :-) Regards Michael I have a problem with creating an XML-document where the returning data from the webservice, have been...
0
by: Jason Shohet | last post by:
There's a 3rd party object that I have, which has a multi-dimensional array on it. I'm getting an error about that multi-dimensional array -- that I can't serialize with it in there. Is there...
0
by: Ken Durden | last post by:
I'm getting the following exception coming out of a block of unmanaged C++ code. Thread executed for 1.03 sec and died with the following exception: External component has thrown an exception. ...
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
0
by: Umut Tezduyar | last post by:
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = "FactorySettings.config"; Configuration config =...
0
by: kbelizabethtan | last post by:
i m using vb.net and mysql to create my project. when i save my data it apear the message that is Error = Only byte array and strings can be serialize by MySqlBinary how do i solve this...
4
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
2
by: =?Utf-8?B?U2hhd24=?= | last post by:
Hi; I would like to be able to use the XMLSerializer to serialize and deserialize a dictionary. is that possible? i know that you can serialize an object that implements the ICollection interface....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.