Gente al cargar una grilla se ejecuta por cada paginado un metodo contra 
Sybase 10. Se ejecuta una, dos, tres, cuatro y a la quinta vez, por ejemplo, 
tira el error Resource governor for 'prepared statements' exceeded .
Les paso el metodo como para aclarar un poco más:

Public Sub GetCategorias()
Try
Dim adpt As OleDbDataAdapter
Dim comm As New OleDbCommand
TablaCategorias = New dsSiMaPa.CategoriasDataTable
If connSiMaPa.State = ConnectionState.Closed Then
connSiMaPa.Open()
End If
comm.Connection = connSiMaPa
comm.CommandType = CommandType.Text
comm.CommandText = "SELECT * FROM Categorias ORDER BY caDescripcion"
adpt = New OleDbDataAdapter(comm)
adpt.Fill(Categorias)
adpt = Nothing
comm = Nothing
Catch ex1 As OleDbException
Console.Write(ex1.Message)
Catch ex2 As Exception
Console.Write(ex2.Message)
End Try
End Sub

o en su defecto en este.

Public Function GetCategoria(ByVal icaId As Integer) As String
Dim sNombre As String
Dim comm As New OleDbCommand
Dim drCategoria As OleDbDataReader
If connSiMaPa.State = ConnectionState.Closed Then
connSiMaPa.Open()
End If
comm.Connection = connSiMaPa
comm.CommandType = CommandType.Text
comm.CommandText = "SELECT caDescripcion FROM Categorias WHERE caId = " & 
icaId.ToString
comm.Prepare()
drCategoria = comm.ExecuteReader
drCategoria.Read()
sNombre = Trim(drCategoria.GetValue(0))
drCategoria.Close()
drCategoria = Nothing
comm = Nothing
Return sNombre
End Function

 

Responder a