dotnet0824
asked on
Dispose dataset
I am using this function to dissociate object reference. In the same function i want to also dissociate (ie dispose Dataset if its passed) How can i achieve it in the same function ... Logic is like if Dataset is passed, dispose it.
public void DissociateObject(System.Ob ject Obj)
{
if (!Obj.Equals(null))
{
Obj = null;
}
}
public void DissociateObject(System.Ob
{
if (!Obj.Equals(null))
{
Obj = null;
}
}
Overloaded function:
public void DissociateObject(System.Ob ject Obj)
{
Obj = null;
}
private void DissociateObject(System.Da ta.DataSet Obj)
{
Obj.Dispose();
Obj = null;
}
public void DissociateObject(System.Ob
{
Obj = null;
}
private void DissociateObject(System.Da
{
Obj.Dispose();
Obj = null;
}
ASKER
Cant i check in the same function--Something like if obj is dataset then dispose... something of that sort
public void DissociateObject(System.Ob
{
if (!Obj.Equals(null))
{
try
{
((IDisposable)Obj).Dispose
}
catch
{
//cast failed
}
Obj = null;
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot..
try checking whether the object implements IDispose