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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

max prepared statements error

Status
Not open for further replies.

sjulian

Programmer
Aug 15, 2000
56
US
I am programming in Visual Basic 2010 and a Sybase database, using ADO.
I have received errors from the database "max prepared statements count exceeded".
I discovered how to raise the max count allowed, but my concern is that I am possibly leaving something "out there" that I should be closing or nulling or something.
My question: does a statement like
Code:
dbconn.Execute(strSQL)
need to be followed by some sort of closing or nulling statement?
I use a lot of recordsets, but I have checked to make sure that they all get closed as soon as I'm done with them and there are never more than a couple open at once.
 

I always put my database access code in a Try...Catch block, then use Finally to clean up. Here's some pseudo code:

Try

Dim a connection and any related objects as necessary
Set up SQL, etc.
Execute SQL code
Commit Transaction if one is being used

Catch ex As Exception

Handle any errors here.
Rollback Transaction if one is being used

Finally

Clean up all objects (e.g., connections, adapters, commands, etc.)
Note: always test that objects exist before trying to close/dispose. For example, with a Connection called Conn:

If Conn IsNot Nothing Then
If Conn.ConnectionState = ConnectionState.Open Then Conn.Close()
Conn.Dispose
End If

End Try

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top