Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

My program hangs after several clicks that access database.

It does not matter what items I click, even if I click the same two buttons that are calling the same sub it hangs after a few times (everytime different number).

 

I have no idea where to start investigating. Can someone

show me the right direction?

 

All I do with database is get a DataReader:

Dim dr As OleDbDataReader = oDbAccess.GetData(sSQL)

Return dr

 

Public Function GetData(ByVal sSQL As String) As OleDbDataReader

Dim oCmd As OleDbCommand = New OleDbCommand(sSQL, cn)

Dim myReader As OleDbDataReader

Try

myReader = oCmd.ExecuteReader()

Return myReader

Catch e As OleDbException

MsgBox(e.Message)

cn.Close()

End Try

End Function

  • Moderators
Posted

You are closing you connection in the Catch, you should do it in the Finally section. While you're at i verify the State first...


Catch e As OleDbException
   MsgBox(e.Message)
Finally
   if cn.state = [i]something[/i].Opened then cn.Close()
'sorry, I don't have .NET handy

End Try

Visit...Bassic Software
Posted
But connection is supposed to stay open. I open it at the beggining and close when application ends. Why would multiple ExecuteReaders (around 20) make the program hang?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...