PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 28 → pool conexion desde .net con windev 18
pool conexion desde .net con windev 18
Débuté par Victor H Pereyra, 28 nov. 2014 20:01 - 1 réponse
Posté le 28 novembre 2014 - 20:01
He logrado hacer por medio del .net pool de conexiones desde windev 18, en esta caso o en mi caso estoy trabajando con INFORMIX

Aqui va las líneas de código final como habilito el pool de conexión y luego proceso varias consulta aleatorias para comprobar el pooling, como es una conexión
nativa solo se puede observar el funcionamiento (apertura y reutilización de conexiones), desde el mismo motor en este INFORMIX. Puede aplicarce a otras BD
con sus DLL o framework correspondientes.

A tener en cuenta. Antes debe incorporar en su proyecto el framework del informix o BD correspondientes que ustedes utilicen, en esta caso o en mi caso es INFORMIX.

Ejemplo:

..NET Assemblies
IBM.Data.Informix
IBM.Data.Informix
IBM.Data.Informix
IfxBlob
IfxClob
IfxCommand
IfxCommandBuilder
IfxCommandInputDialog
IfxCommandTextEditor
IfxConnection
IfxConnectionStringBuilder
IfxConnPropEditor
IfxContext
IfxDataAdapter
IfxDataAdapterWizard
IfxDataReader
IfxDataSourceEnumerator
IfxDateTime
IfxDecimal
IfxEnumerator
IfxEnumerator.IfxEnumResult
IfxEnumerator.IfxEnumResults
IfxError
IfxErrorCollection
IfxException
IfxFactory
IfxInfoMessageEventArgs
IfxInfoMessageEventHandler
IfxMonthSpan
IfxParameter
IfxParameterCollection
IfxParameterCollectionEditor
IfxPermission
IfxPermissionAttribute
IfxRowUpdatedEventArgs
IfxRowUpdatedEventHandler
IfxRowUpdatingEventArgs
IfxRowUpdatingEventHandler
IfxSmartLOB
IfxSmartLOBCreateTimeFlags
IfxSmartLOBFileLocation
IfxSmartLOBLocator
IfxSmartLOBLockMode
IfxSmartLOBOpenMode
IfxSmartLOBWhence
IfxTimeSpan
IfxTimeUnit
IfxTransaction
IfxType
SQLISenseCtrl
VsDesignerUtil
IBM.Data.Utilities


Este es el código

// hora comienzo y final
tHoracom, tHorafin is Time
sConsulta is string
tconsulta is int = 0

tHoracom = TimeSys
tHorafin = TimeSys

// conexion a .net framework 4.5
clConn is IfxConnection


// en el string de conexion puede indicar cuantas conexion iniciales de apertura y cuantas conexiones maximas en este caso 5 min y 50 maximas

clConn.ConnectionString = ("User Id=informix;Password=T697589;Host=172.16.0.8;Server=allende;Service=onsoctcp;Database=db_allende;Pooling=true;Min Pool Size=5;Max Pool Size=50;Persist Security Info=True;")

FOR i = 1 TO 2000000 STEP 100


clConn.Open()

sConsulta=[
SELECT first 60000 recno as Numero, nropac as NumeroPaciente, codana as Codigo FROM la070 WHERE nropac between %1 AND %2
]

// consulta aleatoreas en 100 a 100
sConsulta = StringBuild (sConsulta,200000+i,200000+i+100)


// consulta query
cmd is TO IfxCommand dynamic = new IfxCommand(sConsulta, clConn)
pclMyReader is TO IfxDataReader dynamic = cmd.ExecuteReader()

//ListDeleteAll(LIST_NoName1)
TableDeleteAll(TABLE_NoName1)


// obtengo la respuesta
WHILE pclMyReader.Read()
// cadena = "RECNO:" + pclMyReader.GetString(0) + " - NROPAC: " + pclMyReader.GetString(1) + " - CODANA:" + pclMyReader.GetString(2);
//ListAdd(LIST_NoName1,cadena)
TableAddLine(TABLE_NoName1,pclMyReader.GetString(0),pclMyReader.GetString(1),pclMyReader.GetString(2))

END
sPepe is string = pclMyReader.FieldCount
sPepe= pclMyReader.GetName(0)


// cierro la conexion
clConn.Close()
tconsulta ++

tHorafin = TimeSys
nDifhora is int =TimeDifference( tHoracom , tHorafin)
IF nDifhora >= 3600 THEN
BREAK

END


END

Info("Total consulta en 1 min.",tconsulta)



Un pequeño aporte a la comunidad windev

Saludos
Victor






























Víctor H. Pereyra
M.P. 2595

Departamento de Informática

Sucursal Nva . Cba .: Hipólito Yrigoyen 384
5000 Córdoba, Capital
Tel.: (0351) 426 9200 int :1234

e-mail: vpereyra@sanatorioallende.com
www.sanatorioallende.com.ar




<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial'; COLOR: #000000">
<DIV>He logrado hacer por medio del .net pool de conexiones desde windev 18, en
esta caso o en mi caso estoy trabajando con INFORMIX</DIV>
<DIV>&nbsp;</DIV>
<DIV>Aqui va las líneas de código final como habilito el pool de conexión y
luego proceso varias consulta aleatorias para comprobar el pooling, como es una
conexión </DIV>
<DIV>nativa solo se puede observar el funcionamiento (apertura y reutilización
de conexiones), desde el mismo motor en este INFORMIX. Puede aplicarce a otras
BD</DIV>
<DIV>con sus DLL o framework correspondientes.</DIV>
<DIV>&nbsp;</DIV>
<DIV>A tener en cuenta. Antes debe incorporar en su proyecto el framework del
informix o BD correspondientes que ustedes utilicen, en esta caso o en mi caso
es INFORMIX.</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>Ejemplo</STRONG>:</DIV>
<DIV>&nbsp;</DIV>
<DIV>.NET Assemblies</DIV>
<DIV>&nbsp;&nbsp;&nbsp; IBM.Data.Informix</DIV>
<DIV>IBM.Data.Informix</DIV>
<DIV>IBM.Data.Informix</DIV>
<DIV>IfxBlob</DIV>
<DIV>IfxClob</DIV>
<DIV>IfxCommand</DIV>
<DIV>IfxCommandBuilder</DIV>
<DIV>IfxCommandInputDialog</DIV>
<DIV>IfxCommandTextEditor</DIV>
<DIV>IfxConnection</DIV>
<DIV>IfxConnectionStringBuilder</DIV>
<DIV>IfxConnPropEditor</DIV>
<DIV>IfxContext</DIV>
<DIV>IfxDataAdapter</DIV>
<DIV>IfxDataAdapterWizard</DIV>
<DIV>IfxDataReader</DIV>
<DIV>IfxDataSourceEnumerator</DIV>
<DIV>IfxDateTime</DIV>
<DIV>IfxDecimal</DIV>
<DIV>IfxEnumerator</DIV>
<DIV>IfxEnumerator.IfxEnumResult</DIV>
<DIV>IfxEnumerator.IfxEnumResults</DIV>
<DIV>IfxError</DIV>
<DIV>IfxErrorCollection</DIV>
<DIV>IfxException</DIV>
<DIV>IfxFactory</DIV>
<DIV>IfxInfoMessageEventArgs</DIV>
<DIV>IfxInfoMessageEventHandler</DIV>
<DIV>IfxMonthSpan</DIV>
<DIV>IfxParameter</DIV>
<DIV>IfxParameterCollection</DIV>
<DIV>IfxParameterCollectionEditor</DIV>
<DIV>IfxPermission</DIV>
<DIV>IfxPermissionAttribute</DIV>
<DIV>IfxRowUpdatedEventArgs</DIV>
<DIV>IfxRowUpdatedEventHandler</DIV>
<DIV>IfxRowUpdatingEventArgs</DIV>
<DIV>IfxRowUpdatingEventHandler</DIV>
<DIV>IfxSmartLOB</DIV>
<DIV>IfxSmartLOBCreateTimeFlags</DIV>
<DIV>IfxSmartLOBFileLocation</DIV>
<DIV>IfxSmartLOBLocator</DIV>
<DIV>IfxSmartLOBLockMode</DIV>
<DIV>IfxSmartLOBOpenMode</DIV>
<DIV>IfxSmartLOBWhence</DIV>
<DIV>IfxTimeSpan</DIV>
<DIV>IfxTimeUnit</DIV>
<DIV>IfxTransaction</DIV>
<DIV>IfxType</DIV>
<DIV>SQLISenseCtrl</DIV>
<DIV>VsDesignerUtil</DIV>
<DIV>&nbsp;&nbsp;&nbsp; IBM.Data.Utilities</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>Este es el código</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV>// hora comienzo y final</DIV>
<DIV>tHoracom, tHorafin is Time</DIV>
<DIV>sConsulta is string</DIV>
<DIV>tconsulta is int = 0</DIV>
<DIV>&nbsp;</DIV>
<DIV>tHoracom = TimeSys</DIV>
<DIV>tHorafin = TimeSys</DIV>
<DIV>&nbsp;</DIV>
<DIV>// conexion a .net framework 4.5</DIV>
<DIV>clConn is IfxConnection </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>// en el string de conexion puede indicar cuantas conexion iniciales de
apertura y cuantas conexiones maximas en este caso 5 min y 50 maximas</DIV>
<DIV>&nbsp;</DIV>
<DIV>clConn.ConnectionString = ("User
Id=informix;Password=T697589;Host=172.16.0.8;Server=allende;Service=onsoctcp;Database=db_allende;Pooling=true;Min
Pool Size=5;Max Pool Size=50;Persist Security Info=True;")</DIV>
<DIV>&nbsp;</DIV>
<DIV>FOR i = 1 TO&nbsp; 2000000 STEP 100</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; clConn.Open()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; sConsulta=[</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT first 60000 recno as
Numero, nropac as NumeroPaciente, codana as Codigo FROM la070 WHERE nropac
between %1&nbsp; AND&nbsp; %2</DIV>
<DIV>&nbsp;&nbsp;&nbsp; ]</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; // consulta aleatoreas en 100 a 100</DIV>
<DIV>&nbsp;&nbsp;&nbsp; sConsulta = StringBuild
(sConsulta,200000+i,200000+i+100)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; // consulta query</DIV>
<DIV>&nbsp;&nbsp;&nbsp; cmd&nbsp; is TO IfxCommand dynamic = new
IfxCommand(sConsulta, clConn)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; pclMyReader is TO IfxDataReader dynamic =
cmd.ExecuteReader()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; //ListDeleteAll(LIST_NoName1)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; TableDeleteAll(TABLE_NoName1)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; // obtengo la respuesta</DIV>
<DIV>&nbsp;&nbsp;&nbsp; WHILE pclMyReader.Read()</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // cadena = "RECNO:" +
pclMyReader.GetString(0) + " - NROPAC: " + pclMyReader.GetString(1) + " -
CODANA:" + pclMyReader.GetString(2);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
//ListAdd(LIST_NoName1,cadena)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TableAddLine(TABLE_NoName1,pclMyReader.GetString(0),pclMyReader.GetString(1),pclMyReader.GetString(2))</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; END</DIV>
<DIV>&nbsp;&nbsp;&nbsp; sPepe is string = pclMyReader.FieldCount</DIV>
<DIV>&nbsp;&nbsp;&nbsp; sPepe= pclMyReader.GetName(0)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; // cierro la conexion</DIV>
<DIV>&nbsp;&nbsp;&nbsp; clConn.Close()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; tconsulta ++</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; tHorafin = TimeSys</DIV>
<DIV>&nbsp;&nbsp;&nbsp; nDifhora is int =TimeDifference( tHoracom ,
tHorafin)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; IF nDifhora &gt;= 3600 THEN</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BREAK</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; END</DIV>
<DIV>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>END</DIV>
<DIV>&nbsp;</DIV>
<DIV>Info("Total consulta en 1 min.",tconsulta)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Un pequeño aporte a la comunidad windev</DIV>
<DIV>&nbsp;</DIV>
<DIV>Saludos</DIV>
<DIV>Victor</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV> </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Víctor H. Pereyra </DIV>
<DIV>M.P. 2595 </DIV>
<DIV>&nbsp;</DIV>
<DIV>Departamento de Informática </DIV>
<DIV>&nbsp;</DIV>
<DIV>Sucursal Nva . Cba .: Hipólito Yrigoyen 384 </DIV>
<DIV>5000 Córdoba, Capital </DIV>
<DIV>Tel.: (0351) 426 9200 int :1234 </DIV>
<DIV>&nbsp;</DIV>
<DIV>e-mail: vpereyra@sanatorioallende.com </DIV>
<DIV>www.sanatorioallende.com.ar </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV></DIV></BODY></HTML>
Membre enregistré
51 messages
Popularité : +2 (2 votes)
Posté le 05 décembre 2014 - 10:22
Gracias por la aportación Victor.

--
Salvador Soler.
María Soler.
Distribuidores de PcSoft en España.
www.windeveloper.es
s.soler@serival.es