Releases the unmanaged and, optionally, the managed resources used by the OdbcConnection.
[Visual Basic] Overrides Overloads Protected Sub Dispose( _ ByVal disposing As Boolean _ ) [C#] protected override void Dispose( bool disposing ); [C++] protected: void Dispose( bool disposing ); [JScript] protected override function Dispose( disposing : Boolean );
This method is called by the public
When the disposing parameter is true, the method releases all resources held by any managed objects that this OdbcCommand references. It does this by invoking the Dispose() method of each referenced object.
For more information about Dispose and Finalize, see
[Visual Basic, C#, C++] The following example creates an OdbcConnection and then disposes of it.
[Visual Basic] Public Sub OdbcConnectionHereAndGone() Dim myConnection As New _ OdbcConnection("DRIVER={SQL Server};SERVER=MyServer;" & _ "Trusted_connection=yes;DATABASE=northwind;") myConnection.Open() 'Calling Dispose also calls OdbcConnection.Close. myConnection.Dispose() End Sub [C#] public void OdbcConnectionHereAndGone() { OdbcConnection myConnection = new OdbcConnection("DRIVER={SQL Server};SERVER=MyServer;" + "Trusted_connection=yes;DATABASE=northwind;"); myConnection.Open(); //Calling Dispose also calls OdbcConnection.Close. myConnection.Dispose(); } [C++] public: void OdbcConnectionHereAndGone() { OdbcConnection* myConnection = new OdbcConnection(S"DRIVER= {SQL Server};SERVER=MyServer; Trusted_connection=yes;DATABASE=northwind;"); myConnection->Open(); //Calling Dispose also calls OdbcConnection::Close. myConnection->Dispose(); };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
OdbcConnection Class | OdbcConnection Members | System.Data.Odbc Namespace | OdbcConnection.Dispose Overload List