Create copy of the object

J

Jul

Hi,

I need to create copy (clone) the OracleConnection object.
The OracleConnection class does not contain "Clone" method for creating
copy.
It contains Protected MemberwiseClone

but if use this method:
conDB = CType(conValue.MemberwiseClone(), OracleConnection)

(it is an example from help)

the VS returns error: method is not accessible in this contest because it
is 'Protected'

How this method can be used or any another way to copy object?

Thanks
 
D

David Browne

Jul said:
Hi,

I need to create copy (clone) the OracleConnection object.

I doubt that.
The OracleConnection class does not contain "Clone" method for creating
copy.
It contains Protected MemberwiseClone

but if use this method:
conDB = CType(conValue.MemberwiseClone(), OracleConnection)

(it is an example from help)

the VS returns error: method is not accessible in this contest because it
is 'Protected'

How this method can be used or any another way to copy object?

You can't copy an OracleConnection since it wraps an OCI session. You can
always create another OracleConnection with the same connection string.

David
 
J

Jul

David Browne said:
I doubt that.

Why? The called module is DLL, sure it can open another connection but why
not use the previous one?
Anyway , you already answered that I can not create a copy, thanks.

Maybe you also know the answer to my second question - I posted it with
subject "Declare as Public at different modules"
 
G

Gerald Hernandez

Do you want another reference to the same connection object?
Then just create another variable type of OracleConnection and assign it to
an existing one.
Note however they are the same object instance, not a new connection.
If you close, etc., one, you close them both.

If you want another one with the same parameters, then you need to create a
new one. You could copy the appropriate parameters such as connection string
and such from the original. These would then be 2 seperate connections.

Gerald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top