dispose an object

RonR

Well-known member
Joined
Nov 23, 2007
Messages
82
Programming Experience
5-10
'UPGRADE_NOTE: Object CN1 may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'


CN1 = Nothing


this is the code to Dispose the object.

' Visual Basic 2008
Dim x As New Button
x.Text = "Goodbye"
x.Dispose()


it will not accept CN1.Dispose
 
Before posting, think about what we know about your project (i.e. nothing) and what information we may need in order to be able to answer your question. We don't even know what CN1 is, so how can we tell you what to do with it?
 
What do you mean by "won't accept"? Dispose is a member of the OleDbConnection class so you can call Dispose on an OleDbConnection variable. If you are only using your connection, or any disposable object for that matter, locally then you should employ a Using block to ensure object disposal:
VB.NET:
Using connection As New OleDbConnection("connection string here")
    'Use connection here.
End Using
If you're still having issues then maybe you need to show us your actual code.
 
when I exit my program I close the connection to the Access DB.

CN1.Close()

CN1 = Nothing



when I type: CN1.dispose a little menu pops up that only gives me the option of defaultdatabase



'UPGRADE_NOTE: Object CN1 may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
 
Back
Top