Código:
Resulta que cuando hago alguna consulta o insert demora mucho, ahora el programa está a prueba y la base de datos tiene pocos datos, pero se prevee un crecimiento bastante grande para la misma y no se cómo mejorar el tiempo de respuesta.Public Function AbrirConexion(ByRef NomConexion As Object, NomDSN As String, NomBD As String, NUsuario As String, NClave As String, Optional NHost As String) Dim connectOut As String * 256 Dim connectOutLen As Integer Dim rc As Long Dim Origen As String Dim Aux_hEnv As Long, Aux_hDbc As Long, Aux_hStmt As Long, Aux_Stmt2 As Long On Error GoTo Terminar Prop_HuboError = False NomBD = Trim(NomBD) NomDSN = Trim(NomDSN) If NomDSN <> Empty Then 'CONECTAMOS Origen = "DSN=" & NomDSN & ";DATABASE=" & NomBD & ";UID=" & NUsuario & ";PWD=" & NClave & ";HostName=" & NHost & ";" 'MsgBox "ApiOdbc:" & Origen connectOutLen = 0 connectOut = String(256, 0) rc = SQLAllocEnv(Aux_hEnv) NomConexion.hEnv = Aux_hEnv If Not (rc = SQL_SUCCESS Or rc = SQL_SUCCESS_WITH_INFO) Then DescribeError NomConexion, rc AbrirConexion = False Exit Function End If rc = SQLAllocConnect(ByVal Aux_hEnv, Aux_hDbc) NomConexion.hdbc = Aux_hDbc If Not (rc = SQL_SUCCESS Or rc = SQL_SUCCESS_WITH_INFO) Then DescribeError NomConexion, rc AbrirConexion = False Exit Function End If rc = SQLDriverConnect(Aux_hDbc, 0, Origen, Len(Origen), connectOut, 255, connectOutLen, SQL_DRIVER_COMPLETE) NomConexion.hdbc = Aux_hDbc If Not (rc = SQL_SUCCESS Or rc = SQL_SUCCESS_WITH_INFO) Then DescribeError NomConexion, rc AbrirConexion = False Exit Function End If rc = SQLAllocStmt(ByVal Aux_hDbc, Aux_hStmt) NomConexion.hstmt = Aux_hStmt If Not (rc = SQL_SUCCESS Or rc = SQL_SUCCESS_WITH_INFO) Then DescribeError NomConexion, rc AbrirConexion = False Exit Function End If AbrirConexion = True End If Exit Function Terminar: AbrirConexion = False Prop_HuboError = True End Function
quizá se pueda manejar a través de store procedures, pero busqué como es el manejo y no tuve suerte.
¿Hay alguna forma de conexión más rápida?
Saludos. Fdnds