FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Consulta Ado con Fw vs VB - Solucionado
Posts: 14
Joined: Mon Jul 16, 2012 10:31 AM
Consulta Ado con Fw vs VB - Solucionado
Posted: Sat Jun 20, 2015 09:47 PM
Hola Gente:
Buenas tardes.
Para solicitarles su ayuda en este tema.
Estoy accesando a una Bd Progress y hago una consulta para traer en un Recordset.
El tema es que haciendo la misma consulta con Fw y comparando con VB6.
- Tiempo con FW = 03:00 minutos.
- Tiempo con VB6= 00:10 sgdos.

Algo estar茅 haciendo incorrectamente ?
Pego aqu铆 el c贸digo que estoy utilizando:

Code (fw): Select all Collapse
FUNCTION fConecSrvAdo(xcCnxStr,xnCursor)
聽 聽 聽LOCAL xoCnxSrv:=NIL, oError
聽 聽 聽MsgWait( "Estableciendo conexi贸n con el Servidor ...")
聽 聽 聽xnCursor :=IF(xnCursor==NIL,adUseServer,xnCursor) 聽// adUseClient聽 聽
聽 聽 聽TRY
聽 聽 聽 聽xoCnxSrv := TOleAuto():New( "ADODB.Connection" ) 聽 聽 
聽 聽 聽CATCH oErr
聽 聽 聽 聽MsgStop("No se puede establecer conexion con el Servidor de Base Datos ...!")
聽 聽 聽 聽ShowErrorCnx( oErr ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END 聽 
聽 聽 聽xoCnxSrv:ConnecTionString:=xcCnxStr
聽 聽 聽xoCnxSrv:CursorLocation 聽:=xnCursor
聽 聽 聽TRY
聽 聽 聽 聽xoCnxSrv:Open()
聽 聽 聽CATCH oErr
聽 聽 聽 聽MsgStop("No se puede establecer conexion con el Servidor de Base Datos ...!")
聽 聽 聽 聽ShowErrorCnx( oErr )
聽 聽 聽 聽RETURN NIL
聽 聽 聽END 聽 
聽 聽 聽RETURN xoCnxSrv
*
/*** Funci贸n para Crear RecordSet ***/
* 聽xoCnxSrv 聽: Servidor Conectado
* 聽xcCmdSql 聽: Consulta Sql
* 聽xnCursor 聽: Que lado estar谩 el cursor del Server o Cliente.
* 聽xnLockType: Bloqueo del cursor.
* 聽xnCurType : Tipo de cursor
*聽 聽 
FUNCTION fCreaRecSet(xoCnxSrv, xcCmdSql, xnCursor, xnLockType, xnCurType)
聽 聽 聽LOCAL oRsLocal, oError 聽 
聽 聽 聽TRY 
聽 聽 聽 聽oRsLocal := TOleAuto():New( "ADODB.RecordSet" ) 聽 聽 聽
聽 聽 聽CATCH oError
聽 聽 聽 聽MsgStop('No se puede establecer conexion con Recordset ...!')
聽 聽 聽 聽ShowErrorCnx( oError ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END 聽 
聽 聽 聽xnCursor 聽:=IF(xnCursor=NIL,adUseServer,xnCursor) 聽// adUseClient
聽 聽 聽xnLockType:=IF(xnLockType=NIL,adLockOptimistic,xnLockType)
聽 聽 聽xnCurType :=IF(xnCurType=NIL,adOpenKeyset,xnCurType)
聽 聽 聽oRsLocal:CursorLocation:=xnCursor
聽 聽 聽oRsLocal:LockType 聽 聽 聽:=xnLockType
聽 聽 聽oRsLocal:CursorType 聽 聽:=xnCurType 聽 聽
聽 聽 聽oRsLocal:Source 聽 聽 聽 聽:=xcCmdSql
聽 聽 聽oRsLocal:ActiveConnection:=xoCnxSrv 聽 
聽 聽 聽TRY
聽 聽 聽 聽oRsLocal:Open()
聽 聽 聽CATCH oError
聽 聽 聽 聽MsgStop('No se puede establecer conexion con Recordset ...!')
聽 聽 聽 聽ShowErrorCnx( oError ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END
聽 聽 聽IF !oRsLocal:EOF()
聽 聽 聽 聽oRsLocal:MoveFirst()
聽 聽 聽ENDIF聽 聽
聽 聽 聽RETURN oRsLocal
*聽 聽 
/*** Manejador error para Conexion Server ***/
FUNCTION ShowErrorCnx( oError )
聽 聽 聽LOCAL cError := ""
聽 聽 聽cError += " Descripci贸n 聽: " + oError:Description
聽 聽 聽cError += " SubSystem 聽 聽: " + oError:SubSystem
聽 聽 聽cError += " Error Number : " + Str( oError:SubCode )
聽 聽 聽cError += " Severity 聽 聽 : " + Str( oError:Severity ) 聽 
聽 聽 聽RETURN NIL


y este es con VB6
Code (fw): Select all Collapse
 聽 
/ *** 聽Conectando con el Servidor. ***/
Set cCnx = New ADODB.Connection
聽 聽cCnx = "DSN=Chessgps;HOST=chess;PORT=2500;DB=distrib;UID=SYSPROGRESS;PWD=ch1573"
聽 聽With cCnx
聽 聽 聽' Cursor en Cliente para poder usar un DataGrid
聽 聽 聽.CursorLocation = adUseClient
聽 聽 聽' Abro la conexi贸n con la base de datos usando un DSN
聽 聽 聽.Open cCnx
聽 聽End With

/*** 聽Conectando al Recordset.***/

聽 聽 聽Dim rs As New ADODB.Recordset
聽 聽 聽rs.CursorLocation = adUseClient
聽 聽 聽rs.Open SQL, cCnx, adOpenStatic
聽 聽 聽Set rs.ActiveConnection = Nothing


Atte.
Lucho Montero.
Lima - Per煤.

-----------------------------------------------------------------------
FW 12.04 + xHarbour 123 + Borland 582
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Ado con Fw vs VB
Posted: Sun Jun 21, 2015 10:11 PM

Lucho,

Puedes publicar el resto del c贸digo en VB6 para compararlos ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 14
Joined: Mon Jul 16, 2012 10:31 AM
Re: Consulta Ado con Fw vs VB
Posted: Mon Jun 22, 2015 03:42 PM
Estimado Antonio:
Muchas gracias por responder.
Antes de analizar el resto del c贸digo de VB, por favor analicemos estas l铆neas en donde se ejecuta la consulta tanto en FW como VB6; y es aqu铆 en donde hago la medici贸n de tiempos:

Con Fw:
Code (fw): Select all Collapse
聽 Llama la funci贸n que ejecuta la Consulta y genera el Recordset:

聽 oRsAprvt:=''
聽 oRsAprvt:=fCreaRecSet(oCnxSrv, cCmdSql, adUseClient, adLockOptimistic, adOpenStatic)

Esta es la funci贸n que ejecuta la consulta y crea el Recordset:

FUNCTION fCreaRecSet(xoCnxSrv, xcCmdSql, xnCursor, xnLockType, xnCurType)
聽 聽 聽LOCAL oRsLocal, oError 聽 
聽 聽 聽TRY 
聽 聽 聽 聽oRsLocal := TOleAuto():New( "ADODB.RecordSet" ) 聽 聽 聽
聽 聽 聽CATCH oError
聽 聽 聽 聽MsgStop('No se puede establecer conexion con Recordset ...!')
聽 聽 聽 聽ShowErrorCnx( oError ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END 聽 
聽 聽 聽xnCursor 聽:=IF(xnCursor=NIL,adUseServer,xnCursor) 聽// adUseClient
聽 聽 聽xnLockType:=IF(xnLockType=NIL,adLockOptimistic,xnLockType)
聽 聽 聽xnCurType :=IF(xnCurType=NIL,adOpenKeyset,xnCurType)
聽 聽 聽oRsLocal:CursorLocation:=xnCursor
聽 聽 聽oRsLocal:LockType 聽 聽 聽:=xnLockType
聽 聽 聽oRsLocal:CursorType 聽 聽:=xnCurType 聽 聽
聽 聽 聽oRsLocal:Source 聽 聽 聽 聽:=xcCmdSql
聽 聽 聽oRsLocal:ActiveConnection:=xoCnxSrv 聽 
聽 聽 聽TRY
聽 聽 聽 聽oRsLocal:Open() 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 =====> Aqu铆 es donde se ejecuta la consulta .... tiempo: 03:00 Minutos.
聽 聽 聽CATCH oError
聽 聽 聽 聽MsgStop('No se puede establecer conexion con Recordset ...!')
聽 聽 聽 聽ShowErrorCnx( oError ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END
聽 聽 聽IF !oRsLocal:EOF()
聽 聽 聽 聽oRsLocal:MoveFirst()
聽 聽 聽ENDIF聽 聽
聽 聽 聽RETURN oRsLocal


Este el c贸digo VB que ejecuta la Consulta y crea el Recordset:
Code (fw): Select all Collapse
 聽 聽 Dim rs As New ADODB.Recordset
聽 聽 聽rs.CursorLocation = adUseClient
聽 聽 聽rs.Open SQL, cCnx, adOpenStatic 聽 聽 聽 聽 聽====> Aqu铆 es donde se Ejecuta la Consulta ... tiempo: 00:10 sgdos.
聽 聽 聽Set rs.ActiveConnection = Nothing



Este es el c贸digo de VB que hace lo mismo con FW. Ambos hacen exactamente la misma consulta y la muestran en una grilla.
Code (fw): Select all Collapse
Option Explicit

'Database fields names from SQL query
Const DB_CSUP = "c_super"
Const DB_CVEN = "c_perso"
Const DB_TVEN = "d_perso"
Const DB_CRUT = "ruta"
Const DB_TDESRUT = "d_ruta"
Const DB_CCLI = "idcliente"
Const DB_TNOMREP = "nomcli"
' DB_FECENTRE 聽:= "fecentre"
Const DB_CTIP = "iddocument"
Const DB_NFAC = "nroped"
Const DB_CARTAG = "c_artag"
Const DB_DARTAG = "d_artag"
Const DB_CSUBAG1 = "c_subag1"
Const DB_DSUBAG1 = "d_subag1"
Const DB_CCODART = "codart"
Const DB_TDESART = "descrip"
Const DB_QCANPED = "nqbultos"
Const DB_QUMVTA = "umedstd"
Const DB_QIMPORTE = "qimporte"

'Cube fields names, arbitrary
'Definir Descripcion Campos de la Tabla Contenedora del Cubo.
聽 聽 聽
Const CUBEFLD_CSUP = "Cod Supervisor"
Const CUBEFLD_CVEN = "Cod Prevendedor"
Const CUBEFLD_TVEN = "Nombre Prevendedor"
Const CUBEFLD_CRUT = "Cod Ruta"
Const CUBEFLD_TDESRUT = "Descripcion Ruta"
Const CUBEFLD_CCLI = "Cod Cliente"
Const CUBEFLD_TNOMREP = "Nombre del Cliente"
' CUBEFLD_FECENTRE 聽:= "Fecha Entrega"
Const CUBEFLD_CTIP = "Tipo Documento"
Const CUBEFLD_NFAC = "Numero Pedido"
Const CUBEFLD_CARTAG = "Agrup Articulo"
Const CUBEFLD_DARTAG = "Descripcion Agrupa Articulo"
Const CUBEFLD_CSUBAG1 = "Sub Agrup Articulo"
Const CUBEFLD_DSUBAG1 = "Descripcion Sub Agrup Articulo"
Const CUBEFLD_CCODART = "Cod Articulo"
Const CUBEFLD_TDESART = "Descripcion Articulo"
Const CUBEFLD_QCANPED = "Cantidad Bultos"
Const CUBEFLD_QUMVTA = "Cantida Umed"
Const CUBEFLD_QIMPORTE = "Importe Soles"


'Const CUBEFLD_C_SUPER = "Supervisor"
'Const CUBEFLD_C_PERSO = "Cod Vend"
'Const CUBEFLD_D_PERSO = "Nombre Vendedor"
'Const CUBEFLD_FECENTRE = "Fecha Entrega"
'Const CUBEFLD_CODART = "Cod Articulo"
'Const CUBEFLD_DESCRIP = "Nombre Articulo"
'Const CUBEFLD_QCANPED = DB_QCANPED
'Const CUBEFLD_CANT = DB_CANT

'Const CUBEFLD_CATEGORY = DB_CATEGORY
'Const CUBEFLD_PRODUCT = DB_PRODUCT
'Const CUBEFLD_DATE = "Date"
'Const CUBEFLD_YEAR = "Year"
'Const CUBEFLD_QUARTER = "Quarter"
'Const CUBEFLD_MONTH = "Month"
'Const CUBEFLD_QUANTITY = DB_QUANTITY
'Const CUBEFLD_AMOUNT = DB_AMOUNT


Const xCmdSql1 = "SELECT PUB.perscom.c_super AS c_super, PUB.carga.c_perso AS c_perso, PUB.perscom.d_perso AS d_perso, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.carga.ruta AS ruta, PUB.rutasv.d_ruta AS d_ruta, PUB.carga.idcliente AS idcliente, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.clientes.nomcli AS nomcli, "
Const xCmdSql2 = "PUB.carga.iddocumento AS iddocument, PUB.carga.fecentre AS fecentre, PUB.carga.nroped AS nroped, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.artagru.c_artag AS c_artag, PUB.foragru.d_artag AS d_artag, PUB.artagru.c_subag1 AS c_subag1, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.subagru1.d_subag1 AS d_subag1, PUB.lincarga.codart AS codart, PUB.articulos.descrip AS descrip, " & vbCrLf & _
聽 聽 聽 聽 聽"(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto AS nqbultos, "
Const xCmdSql3 = "(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto * PUB.articulos.valor AS umedstd, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.lincarga.cant * PUB.lincarga.precio + PUB.lincarga.resto * (PUB.lincarga.precio / PUB.articulos.resto) + PUB.lincarga.iva1 + PUB.lincarga.per212 AS qimporte "
Const xCmdSql4 = "FROM 聽PUB.artagru, PUB.foragru, PUB.subagru1, PUB.lincarga, PUB.carga, PUB.articulos, PUB.perscom, PUB.rutasv, PUB.clientes " & vbCrLf & _
聽 聽 聽 聽 聽"WHERE PUB.artagru.c_artag = PUB.foragru.c_artag AND PUB.artagru.c_artag = PUB.subagru1.c_artag AND PUB.artagru.c_subag1 = PUB.subagru1.c_subag1 AND " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.artagru.codart = PUB.articulos.codart AND PUB.lincarga.nroped = PUB.carga.nroped AND PUB.lincarga.codart = PUB.articulos.codart AND "
Const xCmdSql5 = "PUB.carga.idSucur = PUB.perscom.idSucur AND PUB.carga.c_perso = PUB.perscom.c_perso AND PUB.carga.idSucur = PUB.rutasv.idSucur AND " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.carga.ruta = PUB.rutasv.ruta AND PUB.carga.idSucur = PUB.clientes.idSucur AND PUB.carga.idcliente = PUB.clientes.idcliente AND " & vbCrLf & _
聽 聽 聽 聽 聽"(PUB.artagru.c_artag = 21) AND (PUB.carga.idSucur = 1)"
Const SQL = xCmdSql1 + xCmdSql2 + xCmdSql3 + xCmdSql4 + xCmdSql5
Dim cCnx As ADODB.Connection
Private CONS As String


Private Sub ContourCubeX1_BeforeMoveDimension(ByVal ViewDim As CCubeX4.IViewDim, ByVal NewAxis As CCubeX4.TxDimAxis, ByVal NewPos As Long, ByVal Cancel As CCubeX4.IBoolean)
聽 Select Case ViewDim.Name
聽 聽 Case CUBEFLD_CCODART
聽 聽 聽 If NewAxis <> xda_outside Then
聽 聽 聽 聽 聽 聽 If NewAxis <> ContourCubeX1.Cube.Dims(CUBEFLD_CCODART).Axis Then
聽 聽 聽 聽 聽 聽 聽 Cancel.Value = True
聽 聽 聽 聽 聽 聽 Else
聽 聽 聽 聽 聽 聽 聽 If NewPos <= ContourCubeX1.Cube.Dims(CUBEFLD_TDESART).Pos Then Cancel.Value = True
聽 聽 聽 聽 聽 聽 End If
聽 聽 聽 End If
聽 聽 Case CUBEFLD_CVEN
聽 聽 聽 If NewAxis <> xda_outside Then
聽 聽 聽 聽 聽If NewAxis <> ContourCubeX1.Cube.Dims(CUBEFLD_CVEN).Axis Then
聽 聽 聽 聽 聽 聽Cancel.Value = True
聽 聽 聽 聽 聽Else
聽 聽 聽 聽 聽 聽If NewPos >= ContourCubeX1.Cube.Dims(CUBEFLD_TVEN).Pos Then Cancel.Value = True
聽 聽 聽 聽 聽End If
聽 聽 聽 End If
聽 End Select
End Sub

Private Sub Form_Load()
聽 聽On Error GoTo handler
聽 聽' Instancio la conexi贸n y me conecto con la base de datos
聽 聽' ----------------------------------------------------------
聽 聽Set cCnx = New ADODB.Connection
聽 聽cCnx = "DSN=Chessgps;HOST=chess;PORT=2500;DB=distrib;UID=SYSPROGRESS;PWD=ch1573"
聽 聽With cCnx
聽 聽 聽' Cursor en Cliente para poder usar un DataGrid
聽 聽 聽.CursorLocation = adUseClient
聽 聽 聽' Abro la conexi贸n con la base de datos usando un DSN
聽 聽 聽.Open cCnx
聽 聽End With
聽 聽ContourCubeX1.BorderStyle = xcbsSingle
聽 聽ContourCubeX1.NULLValueString = ""
聽 聽ContourCubeX1.InactiveDimAreaBkColor = 2
聽 聽 聽 
聽 聽
聽 聽With ContourCubeX1.Cube
聽 聽 聽'Create Dimensions and Facts in cube
聽 聽 聽' Dimensions initially appeared on verical axis
聽 聽 聽
聽 聽 聽.Dims.Add CUBEFLD_CSUP, DB_CSUP, 5, 2
聽 聽 聽.Dims.Add CUBEFLD_CVEN, DB_CVEN, 5, 2
聽 聽 聽.Dims.Add CUBEFLD_TVEN, DB_TVEN, 1, 2
聽 聽 聽.Dims.Add CUBEFLD_CRUT, DB_CRUT, 5, 2
聽 聽 聽.Dims.Add CUBEFLD_TDESRUT, DB_TDESRUT, 1, 2
聽 聽 聽.Dims.Add CUBEFLD_CCLI, DB_CCLI, 5, 2
聽 聽 聽.Dims.Add CUBEFLD_TNOMREP, DB_TNOMREP, 1, 2
聽 聽 聽':Dims:Add(CUBEFLD_FECENTRE, DB_FECENTRE, 9, 2)
聽 聽 聽.Dims.Add CUBEFLD_CTIP, DB_CTIP, 1, 2
聽 聽 聽.Dims.Add CUBEFLD_NFAC, DB_NFAC, 5, 2
聽 聽 聽
聽 聽 聽' Mostrar Fijos Verticales al presentar el Cubo.
聽 聽 聽.Dims.Add CUBEFLD_CARTAG, DB_CARTAG, 5, 0
聽 聽 聽.Dims.Add CUBEFLD_DARTAG, DB_DARTAG, 1, 0
聽 聽 聽.Dims.Add CUBEFLD_CSUBAG1, DB_CSUBAG1, 5, 0
聽 聽 聽.Dims.Add CUBEFLD_DSUBAG1, DB_DSUBAG1, 1, 0
聽 聽 聽.Dims.Add CUBEFLD_CCODART, DB_CCODART, 5, 0
聽 聽 聽.Dims.Add CUBEFLD_TDESART, DB_TDESART, 1, 0
聽 聽 聽
聽 聽 聽'Cube facts
聽 聽 聽.BaseFacts.Add DB_QCANPED, DB_QCANPED
聽 聽 聽.BaseFacts.Add DB_QUMVTA, DB_QUMVTA
聽 聽 聽.BaseFacts.Add DB_QIMPORTE, DB_QIMPORTE
聽 聽 聽 聽
聽 聽 聽'Add cube facts to the grid
聽 聽 聽.Facts.Add(CUBEFLD_QCANPED, DB_QCANPED, 1).Caption = "Bultos"
聽 聽 聽.Facts.Add(CUBEFLD_QUMVTA, DB_QUMVTA, 1).Caption = " Cantidad Venta UM "
聽 聽 聽.Facts.Add(CUBEFLD_QIMPORTE, DB_QIMPORTE, 1).Caption = "Importe Bruto"

聽 聽 聽'Populate recordset

聽 聽 聽Dim rs As New ADODB.Recordset
聽 聽 聽rs.CursorLocation = adUseClient
聽 聽 聽rs.Open SQL, cCnx, adOpenStatic
聽 聽 聽Set rs.ActiveConnection = Nothing

聽 聽 聽'Activate grid

聽 聽 聽'.Open rs
聽 聽End With
聽 聽ContourCubeX1.Facts(CUBEFLD_QCANPED).Visible = True
聽 聽ContourCubeX1.Facts(CUBEFLD_QCANPED).Appearance.Format = "###,###,##0.00"
聽 聽ContourCubeX1.Facts(CUBEFLD_QUMVTA).Visible = True
聽 聽ContourCubeX1.Facts(CUBEFLD_QUMVTA).Appearance.Format = "###,###,##0.0000"
聽 聽ContourCubeX1.Facts(CUBEFLD_QIMPORTE).Visible = True
聽 聽ContourCubeX1.Facts(CUBEFLD_QIMPORTE).Appearance.Format = "###,###,##0.00"
聽 聽'ContourCubeX1.FlatStyle = xfs_Flat
聽 聽ContourCubeX1.Cube.Open rs
聽
聽 聽
聽 聽infoBox.Text = info
聽Exit Sub
聽 聽 
handler:
聽 MsgBox ("Error: " & Err.Description)
聽 End
End Sub

Private Sub Form_Resize()
聽 聽 ContourCubeX1.Move 0, Image1.Height, Me.ScaleWidth, Me.ScaleHeight - Image1.Height - infoBox.Height
聽 聽 With Image2
聽 聽 聽 聽 .Left = Image1.Width
聽 聽 聽 聽 .Width = IIf((Me.Width - Image1.Width) > 0, Me.Width - Image1.Width, 0)
聽 聽 End With
聽 聽 With infoBox
聽 聽 聽 聽 .Top = Image1.Height + ContourCubeX1.Height
聽 聽 聽 聽 .Width = ContourCubeX1.Width
聽 聽 聽 聽 .Left = 0
聽 聽 End With
End Sub


Saludos.
Atte.
Lucho Montero.
Lima - Per煤.
------------------------------------------------------------------------
FW 12.04 + xHarbour 1.2.3 + Borland 5.8.2
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Ado con Fw vs VB
Posted: Mon Jun 22, 2015 04:43 PM

Lucho,

Le pasas exactamente los mismos par谩metros al c贸digo de FWH que al de VB6 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 14
Joined: Mon Jul 16, 2012 10:31 AM
Re: Consulta Ado con Fw vs VB
Posted: Mon Jun 22, 2015 05:27 PM
Hola Antonio:
As铆 es ... es exactamente la misma consulta, incluso primero la "arm茅" para FW y despu茅s la copi茅 igual a VB6 la 煤nica diferencia que en FW una porci贸n del Where es contra una variable:

Code (fw): Select all Collapse
"(PUB.artagru.c_artag = "+ALLTRIM(STR(nIdAgrart,4))+") AND (PUB.carga.idSucur = "+ALLTRIM(STR(nIdSucur,4))+")


Y en VB6 una parte del Where es contra un valor escrito directamente en la consulta; pero no tendr铆a mayor relevancia:

Code (fw): Select all Collapse
"(PUB.artagru.c_artag = 21) AND (PUB.carga.idSucur = 1)"


Esta es la cadena de la consulta para FW:
Code (fw): Select all Collapse
聽 聽 聽cCmdSql:=''
聽 聽 聽xCmdSql1:=xCmdSql2:=xCmdSql3:=xCmdSql4:=xCmdSql5:=''
聽 聽 聽xCmdSql1:="SELECT PUB.perscom.c_super AS c_super, PUB.carga.c_perso AS c_perso, PUB.perscom.d_perso AS d_perso, "+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 "PUB.carga.ruta AS ruta, PUB.rutasv.d_ruta AS d_ruta, PUB.carga.idcliente AS idcliente, "+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 "PUB.clientes.nomcli AS nomcli, "
聽 聽 聽xCmdSql2:="PUB.carga.iddocumento AS iddocument, PUB.carga.fecentre AS fecentre, PUB.carga.nroped AS nroped, "+;
聽 聽 聽 聽 聽 聽 聽 聽"PUB.artagru.c_artag AS c_artag, PUB.foragru.d_artag AS d_artag, PUB.artagru.c_subag1 AS c_subag1, "+;
聽 聽 聽 聽 聽 聽 聽 聽"PUB.subagru1.d_subag1 AS d_subag1, PUB.lincarga.codart AS codart, PUB.articulos.descrip AS descrip, "+;
聽 聽 聽 聽 聽 聽 聽 聽"(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto AS nqbultos, "
聽 聽 聽xCmdSql3:="(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto * PUB.articulos.valor AS umedstd, "+;
聽 聽 聽 聽 聽 聽 聽 聽"PUB.lincarga.cant * PUB.lincarga.precio + PUB.lincarga.resto * (PUB.lincarga.precio / PUB.articulos.resto) + PUB.lincarga.iva1 + PUB.lincarga.per212 AS qimporte "
聽 聽 聽xCmdSql4:="FROM 聽PUB.artagru, PUB.foragru, PUB.subagru1, PUB.lincarga, PUB.carga, PUB.articulos, PUB.perscom, PUB.rutasv, PUB.clientes "+;
聽 聽 聽 聽 聽 聽 聽 聽"WHERE PUB.artagru.c_artag = PUB.foragru.c_artag AND PUB.artagru.c_artag = PUB.subagru1.c_artag AND PUB.artagru.c_subag1 = PUB.subagru1.c_subag1 AND "+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 "PUB.artagru.codart = PUB.articulos.codart AND PUB.lincarga.nroped = PUB.carga.nroped AND PUB.lincarga.codart = PUB.articulos.codart AND "
聽 聽 聽xCmdSql5:="PUB.carga.idSucur = PUB.perscom.idSucur AND PUB.carga.c_perso = PUB.perscom.c_perso AND PUB.carga.idSucur = PUB.rutasv.idSucur AND "+;
聽 聽 聽 聽 聽 聽 聽 聽"PUB.carga.ruta = PUB.rutasv.ruta AND PUB.carga.idSucur = PUB.clientes.idSucur AND PUB.carga.idcliente = PUB.clientes.idcliente AND "+;
聽 聽 聽 聽 聽 聽 聽 聽"(PUB.artagru.c_artag = "+ALLTRIM(STR(nIdAgrart,4))+") AND (PUB.carga.idSucur = "+ALLTRIM(STR(nIdSucur,4))+") AND (PUB.carga.iddocumento = 'FCVTA' OR PUB.carga.iddocumento = 'BLVTA')"
聽 聽 聽cCmdSql:=xCmdSql1+xCmdSql2+xCmdSql3+xCmdSql4+xCmdSql5


Y esta es la cadena de la Consulta para VB6:
Code (fw): Select all Collapse
Const xCmdSql1 = "SELECT PUB.perscom.c_super AS c_super, PUB.carga.c_perso AS c_perso, PUB.perscom.d_perso AS d_perso, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.carga.ruta AS ruta, PUB.rutasv.d_ruta AS d_ruta, PUB.carga.idcliente AS idcliente, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.clientes.nomcli AS nomcli, "
Const xCmdSql2 = "PUB.carga.iddocumento AS iddocument, PUB.carga.fecentre AS fecentre, PUB.carga.nroped AS nroped, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.artagru.c_artag AS c_artag, PUB.foragru.d_artag AS d_artag, PUB.artagru.c_subag1 AS c_subag1, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.subagru1.d_subag1 AS d_subag1, PUB.lincarga.codart AS codart, PUB.articulos.descrip AS descrip, " & vbCrLf & _
聽 聽 聽 聽 聽"(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto AS nqbultos, "
Const xCmdSql3 = "(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto * PUB.articulos.valor AS umedstd, " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.lincarga.cant * PUB.lincarga.precio + PUB.lincarga.resto * (PUB.lincarga.precio / PUB.articulos.resto) + PUB.lincarga.iva1 + PUB.lincarga.per212 AS qimporte "
Const xCmdSql4 = "FROM 聽PUB.artagru, PUB.foragru, PUB.subagru1, PUB.lincarga, PUB.carga, PUB.articulos, PUB.perscom, PUB.rutasv, PUB.clientes " & vbCrLf & _
聽 聽 聽 聽 聽"WHERE PUB.artagru.c_artag = PUB.foragru.c_artag AND PUB.artagru.c_artag = PUB.subagru1.c_artag AND PUB.artagru.c_subag1 = PUB.subagru1.c_subag1 AND " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.artagru.codart = PUB.articulos.codart AND PUB.lincarga.nroped = PUB.carga.nroped AND PUB.lincarga.codart = PUB.articulos.codart AND "
Const xCmdSql5 = "PUB.carga.idSucur = PUB.perscom.idSucur AND PUB.carga.c_perso = PUB.perscom.c_perso AND PUB.carga.idSucur = PUB.rutasv.idSucur AND " & vbCrLf & _
聽 聽 聽 聽 聽"PUB.carga.ruta = PUB.rutasv.ruta AND PUB.carga.idSucur = PUB.clientes.idSucur AND PUB.carga.idcliente = PUB.clientes.idcliente AND " & vbCrLf & _
聽 聽 聽 聽 聽"(PUB.artagru.c_artag = 21) AND (PUB.carga.idSucur = 1)"
Const SQL = xCmdSql1 + xCmdSql2 + xCmdSql3 + xCmdSql4 + xCmdSql5


Y como dec铆a la diferencia de tiempos es en el Open:
- FW:
Code (fw): Select all Collapse
聽 聽 聽...
聽 聽 ...
聽 聽 聽oRsLocal:Source 聽 聽 聽 聽:=xcCmdSql
聽 聽 聽....
聽 聽 聽 聽oRsLocal:Open()
聽 聽 ...
聽 聽.....


- VB6:
Code (fw): Select all Collapse
rs.Open SQL, cCnx, adOpenStatic
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Ado con Fw vs VB
Posted: Mon Jun 22, 2015 06:33 PM

Si haces el WHERE exactamente igual que en VB6, usando un valor fijo

la diferencia de tiempos se mantiene ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 14
Joined: Mon Jul 16, 2012 10:31 AM
Re: Consulta Ado con Fw vs VB
Posted: Mon Jun 22, 2015 07:51 PM
Hola Antonio:
Haciendo la modificaci贸n de la consulta con valores fijos se mantiene igual.
Insert茅 un Time() antes de entrar al Open: 14:34:30 y al salir del Open: 14:38:04
- FW tiempo : 03':34'' minu

VB6: antes del Open: 14:49:25, saliendo del Open: 14:49:35
- VB6 tiempo : 00':10'' sgdos.

Esta es la consulta y es igual a VB6:
Code (fw): Select all Collapse
 xCmdSql1:="SELECT PUB.perscom.c_super AS c_super, PUB.carga.c_perso AS c_perso, PUB.perscom.d_perso AS d_perso, "+;
                  "PUB.carga.ruta AS ruta, PUB.rutasv.d_ruta AS d_ruta, PUB.carga.idcliente AS idcliente, "+;
                  "PUB.clientes.nomcli AS nomcli, "
     xCmdSql2:="PUB.carga.iddocumento AS iddocument, PUB.carga.fecentre AS fecentre, PUB.carga.nroped AS nroped, "+;
               "PUB.artagru.c_artag AS c_artag, PUB.foragru.d_artag AS d_artag, PUB.artagru.c_subag1 AS c_subag1, "+;
               "PUB.subagru1.d_subag1 AS d_subag1, PUB.lincarga.codart AS codart, PUB.articulos.descrip AS descrip, "+;
               "(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto AS nqbultos, "
     xCmdSql3:="(PUB.lincarga.cant * PUB.articulos.resto + PUB.lincarga.resto) / PUB.articulos.resto * PUB.articulos.valor AS umedstd, "+;
               "PUB.lincarga.cant * PUB.lincarga.precio + PUB.lincarga.resto * (PUB.lincarga.precio / PUB.articulos.resto) + PUB.lincarga.iva1 + PUB.lincarga.per212 AS qimporte "
     xCmdSql4:="FROM  PUB.artagru, PUB.foragru, PUB.subagru1, PUB.lincarga, PUB.carga, PUB.articulos, PUB.perscom, PUB.rutasv, PUB.clientes "+;
               "WHERE PUB.artagru.c_artag = PUB.foragru.c_artag AND PUB.artagru.c_artag = PUB.subagru1.c_artag AND PUB.artagru.c_subag1 = PUB.subagru1.c_subag1 AND "+;
                  "PUB.artagru.codart = PUB.articulos.codart AND PUB.lincarga.nroped = PUB.carga.nroped AND PUB.lincarga.codart = PUB.articulos.codart AND "
     xCmdSql5:="PUB.carga.idSucur = PUB.perscom.idSucur AND PUB.carga.c_perso = PUB.perscom.c_perso AND PUB.carga.idSucur = PUB.rutasv.idSucur AND "+;
               "PUB.carga.ruta = PUB.rutasv.ruta AND PUB.carga.idSucur = PUB.clientes.idSucur AND PUB.carga.idcliente = PUB.clientes.idcliente AND "+;
               "(PUB.artagru.c_artag = 21) AND (PUB.carga.idSucur = 1) AND (PUB.carga.iddocumento = 'FCVTA' OR PUB.carga.iddocumento = 'BLVTA')"
               
     cCmdSql:=xCmdSql1+xCmdSql2+xCmdSql3+xCmdSql4+xCmdSql5
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Ado con Fw vs VB
Posted: Mon Jun 22, 2015 09:56 PM

Lucho,

No es algo de FWH sino de la implementaci贸n de OLE de Harbour

lo 煤nico que se me ocurre es que falte algo en la configuraci贸n que sea lo que causa la diferencia de tiempos.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jun 23, 2015 06:17 AM

Hola,

驴Has mirado que est茅s usando en Fivewin el mismo cursor?.

Tendr谩s que modificar adofuncs.prg para adaptarlo.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jun 23, 2015 12:19 PM

Solo para meter mi cuchara...

No creo que el error sea de HARBOUR sino especificamente de ADORDD.

Para cotejar.. se podria comparar esa consulta contra TDOLPHIN, y ver los tiempos. No contra VB6, que aunque para efectos de desarrollo es lo que se pretende igualar, sino para ver si es la capa de ADO la que ralentiza la consulta.

Luchomontero.. podrias hacer esa prueba. Yo he estado pensando passarme a ADORDD, pero, si las veloidades de las consultas se ralentizan.. definitivamnete NO

Desde Chile
Adolfo

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jun 23, 2015 12:20 PM

Adolfo,

Parece que no est谩 usando AdoRdd...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jun 23, 2015 02:15 PM

Adolfo,

No est谩 usando ADORDD, ni tampoco las funciones de Fivewin que ha creado Nages, sino una funci贸n propia.

Yo, con ADORDD, no tengo ni de lejos esos tiempos de respuesta, y lo tengo ahora puesto a un cliente en una WAN a trav茅s de Internet y de momento va todo fen贸meno.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 1818
Joined: Wed Oct 26, 2005 02:49 PM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jun 23, 2015 03:54 PM
Buenos d铆as...

A mi me sucedi贸 algo similar en una base de datos en postgres... Al realizar la consulta con operaciones de lado servidor se demoraba 01:30 un minuto y treinta segundos. Cualquier operaci贸n tardaba un mont贸n.
Code (fw): Select all Collapse
oVar:="SELECT sum(ss_tothdo),sum(ss_totase),sum(ss_totgrl),sum(ss_cancel),sum(ss_notasd) FROM lyma_cobro_serv WHERE ss_manzan="+vMan+" AND ss_lotesp="+vLot+" AND ss_period<>'"+vPer+"' AND ss_contro='"+vTip+"'"
oRrsDeu := FW_OPENRECORDSET(oLamcla:oCon,oVar,adLockOptimistic,adOpenKeyset)
nRegistros := oRrsDeu:RecordCount()

Asi que para solucionar el problema 煤nicamente realizo la consulta y hago las operaciones de lado del cliente.
Code (fw): Select all Collapse
oVar:="SELECT ss_tothdo,ss_totase,ss_totgrl,ss_cancel,ss_notasd FROM lyma_cobro_serv WHERE ss_manzan="+vMan+" AND ss_lotesp="+vLot+" AND ss_period<>'"+vPer+"' AND ss_contro='"+vTip+"'"
oRrsDeu := FW_OPENRECORDSET(oLamcla:oCon,oVar,adLockOptimistic,adOpenKeyset)
nRegistros := oRrsDeu:RecordCount()
oRrsDeu:MoveFirst()
Do While !oRrsDeu:Eof()
  h2o:=h2o+oLamcla:cNoNulo(oRrsDeu:Fields( "ss_tothdo" ):Value,"N")
  ase:=ase+oLamcla:cNoNulo(oRrsDeu:Fields( "ss_totase" ):Value,"N")
  tot:=tot+oLamcla:cNoNulo(oRrsDeu:Fields( "ss_totgrl" ):Value,"N")
  can:=can+oLamcla:cNoNulo(oRrsDeu:Fields( "ss_cancel" ):Value,"N")
  nta:=nta+oLamcla:cNoNulo(oRrsDeu:Fields( "ss_notasd" ):Value,"N")
  oRrsDeu:MoveNext()
EndDo
oRrsDeu:close()


No se si sea de ayuda... pero as铆 solucione mi problema... Ahora tarda 3 segundos en realizar la misma operaci贸n.
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jun 23, 2015 06:59 PM

google translator:

Si la consulta es usar muchas veces este es un trabajo DBA
Prueba MySql Query Analyser.

Regards

Antonio H Ferreira
Posts: 14
Joined: Mon Jul 16, 2012 10:31 AM
Re: Consulta Ado con Fw vs VB
Posted: Tue Jul 14, 2015 07:27 AM
Estimado Antonio :
Gracias por contestar.

Efectivamente, el problema no viene de FW, sino en el :Open() de ToleAuto de xHarbour que al momento de "traer" la consulta se demora... hice una prueba reemplazando :Open() por :Execute() y mejor贸 algo; de 3 minutos a 2 minutos, aunque todav铆a es lento comparado con Vb 00:10 segundos.
Gracias a los dem谩s colegas que contestaron.
Estoy utilizando Ado para conectarme a la BD Progress y la consulta y el recordset es por el lado del Cliente y trabajo con el recordset desconectado.
No utilizo TDOLPHIN porque creo que est谩 desarrollado para trabajar con MySql.
Adjunto el c贸digo que utilizo y en donde se observa que se reemplaz贸 :Open() por :Execute().

Code (fw): Select all Collapse
 FUNCTION fCreaRecSet(xcCmdSql, xoCnxSrv, xnCurType, xnLockType, xnCursor )
聽 聽 聽LOCAL oRsLocal, oError 聽 
聽 聽 聽TRY 
聽 聽 聽 聽oRsLocal := TOleAuto():New( "ADODB.RecordSet" )
聽 聽 聽CATCH oError
聽 聽 聽 聽MsgStop('No se puede establecer conexion con Recordset ...!')
聽 聽 聽 聽ShowErrorCnx( oError ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END 聽 
聽 聽 聽oRsLocal:Source 聽 聽 聽 聽:=xcCmdSql
聽 聽 聽oRsLocal:ActiveConnection:=xoCnxSrv
聽 聽 聽oRsLocal:CursorType 聽 聽:=xnCurType
聽 聽 聽oRsLocal:LockType 聽 聽 聽:=xnLockType
聽 聽 聽oRsLocal:CursorLocation:=xnCursor
聽 聽 聽TRY
聽 聽 聽 聽*oRsLocal:Open(xcCmdSql, xoCnxSrv, xnCurType, xnLockType)
聽 聽 聽 聽oRsLocal:=xoCnxSrv:Execute(xcCmdSql)
聽 聽 聽 聽*oRsLocal:Open()
聽 聽 聽CATCH oError
聽 聽 聽 聽MsgStop('No se puede establecer conexion con Recordset ...!')
聽 聽 聽 聽ShowErrorCnx( oError ) 聽 聽 聽
聽 聽 聽 聽RETURN NIL
聽 聽 聽END
聽 聽 聽IF !oRsLocal:EOF()
聽 聽 聽 聽oRsLocal:MoveFirst()
聽 聽 聽ENDIF聽 聽
聽 聽 聽RETURN oRsLocal


Alguna sugerencia ser谩 bien recibida.

Saludos.
Atte.
Lucho Montero.
Lima - Per煤.

------------------------------------------------------------
FW 12.04 + xHarbour 1.2.3 + Borland 5.8.2