Cannot close OleDBdatareader/Connection on Sybase

F

Fassa

Hi All,

I've written this simple bit of code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim sybaseconn As OleDbConnection
Dim sybasecmd As OleDbCommand
Dim sybaseReader As OleDbDataReader

sybaseconn = New OleDbConnection()
sybaseconn.ConnectionString() =
"Provider=Sybase.ASEOLEDBProvider;Server Name=**;Initial
Catalog=**;User Id=**;Password=**"
sybaseconn.Open()

sybasecmd = New OleDbCommand("select * from ad where adid =
**", sybaseconn)

sybaseReader = sybasecmd.ExecuteReader

sybaseReader.Read()

MsgBox(sybaseReader(0).ToString)

sybaseReader.Close()
sybaseconn.Close()
End Sub

Now yesterday this code worked jsut fine, today however the code
executes up until the the msgbox statement but when it comes to the
sybasereader.close() statement it just hangs! It refuses to close the
reader!

Whats even more weird is that if I omit the sybaseReader.close()
statement it just hangs then at the sybaseconn.close() statement.

I've read somewhere that if the reader contains a large amount of
information it may take a while but this SQL query only returns one
record!

Has anyone ever experienced anything like this?

It cannot be a driver issue as it will not open the connection if the
drivers were wrong also I've checked with one of our system guys and
there are no erroneous connections to the sybase server either.

Any help will be appreciated.

Thanks!
 
M

Mary Chipman [MSFT]

Take the msgbox statement out of your code and write the values you
want to display to a variable instead. Then call msgbox after you've
closed the connections.

--Mary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top