Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

handle is not initialized

Status
Not open for further replies.

SQL2KDBA69

Programmer
Feb 4, 2004
227
US
Code:
public class dbaccess

Private mcnnAccess As OleDb.OleDbConnection

Public Sub New()

        mcnnAccess = New OleDb.OleDbConnection
        mcnnAccess.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Remote\Serverlist.mdb"
        mcnnAccess.Open()

    End Sub

Public Function GetServer(ByVal pstrdataset As DataSet) As DataSet

        objadapter = New OleDb.OleDbDataAdapter("Select * From Servers", mcnnAccess)
        objadapter.Fill(pstrdataset)
        pstrdataset = pstrdataset

    End Function

Protected Overrides Sub Finalize()
        MyBase.Finalize()
        mcnnAccess.Close()
        mcnnAccess = Nothing
    End Sub

Thats the code in my close and when i call the getserver module and exit the program i get a handle is not initialized error. on the mcnnAccess.Close() line.

any advise is appreciated.
 
i tried that and still get this error

An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll

Additional information: Handle is not initialized.
 
this where where i call the class.

Code:
Public objdataset As DataSet = New DataSet
Public objServer As New clsServers

    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call objServer.GetServer(objdataset)
        
    End Sub
 
Code:
Public objdataset As DataSet = New DataSet
Public objServer As New dbaccess

    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call objServer.GetServer(objdataset)
        
    End Sub

that the right class name
 
i set it here.

Code:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        objServer = Nothing
        objdataset = Nothing
    End Sub
 
i have this in my dbaccess class?

Code:
Protected Overrides Sub Finalize()
        MyBase.Finalize()
        mcnnAccess.Close()
        mcnnAccess = Nothing
    End Sub
 
Are you setting dbaccess = nothing before you call finalize?
NO im not setting dbaccess = nothing any where.
 
Okay, so what's with this code?
Code:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        [b]objServer = Nothing[/b]
        objdataset = Nothing
    End Sub

And where are you calling the .Finalize method from?

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I took that out. I dont call the .Finalize method it auto runs when the app closed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top