FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour FW_DbfSqlQuery con campos mayores de 256 carracteres
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
FW_DbfSqlQuery con campos mayores de 256 carracteres
Posted: Tue Mar 05, 2024 09:49 AM
Hola a todos.

Estoy intentando trabajar con tablas DBF pero mediante consultas SQL pero me encuentro con un problema cuando los campos CARACTER son superiores a 256 caracteres.

He probado hacer las consultas mediante la funci贸n que provee Fivewin FW_DbfSqlQuery(), tambi茅n mediante la conexi贸n con ADO pero la informaci贸n que me devuelve siempre es truncada.

Partiendo de una tabla:
CODIGO LEN 10
NOMBRE LEN 50
OBSERVACION LEN 1024
PAIS LEN 50

Si realizo la siguiente consulta:
Code (fw): Select all Collapse
TEXT INTO cQuery
聽 聽 聽 SELECT CODIGO, NOMBRE, PAIS 
聽 聽 聽 FROM ARTICULO
聽 聽ENDTEXT
聽 聽oRs := FW_DbfSqlQuery( '.\DBF\', cQuery,,.t.)
la informaci贸n del campo PAIS no es correcta, si bajo el tama帽o del campo OBSERVACION a 256 funciona todo bien.

Mediante ADO pasa lo mismo:
Code (fw): Select all Collapse
oC := win_oleCreateObject( "ADODB.Connection" )
oC:Open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source="' + cPath + '";Extended Properties=dBASE IV;User ID=Admin;Password=;')
oRs := win_oleCreateObject( "ADODB.Recordset" )
TEXT INTO cQuery
聽 SELECT CODIGO, NOMBRE, PAIS 
聽 FROM ARTICULO
ENDTEXT
oRs:Open( cQuery, oC )
He estado buscando informaci贸n al respecto y en DBase IV hay una limitaci贸n a 256 caracteres como m谩ximo en un campo de la tabla DBF. Esto se aumento en DBase V hasta 2048, pero no he encontrado la cadena de conexi贸n con DBase V para ADO. He probado cambiando directamente DBase IV por DBase V en la cadena de conexi贸n pero no funciona.

Gracias y salud!
--------

驴 Y porque no ?

驴 And why not ?
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW_DbfSqlQuery con campos mayores de 256 carracteres
Posted: Tue Mar 05, 2024 03:01 PM

Please try

VFPOLEDB

oledb for foxpro

Regards



G. N. Rao.

Hyderabad, India
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: FW_DbfSqlQuery con campos mayores de 256 carracteres
Posted: Fri Mar 08, 2024 02:36 PM
Thanks for the reply.

I have installed the driver from the following address:
https://www.microsoft.com/en-us/download/details.aspx?id=32602

I have tried with the connection string:
Code (fw): Select all Collapse
oC:Open('Provider=vfpoledb;Data Source='+cPath+';Collating Sequence=general;')
and the result is the same, when there are fields longer than 256 characters, the information in subsequent fields is returned truncated.

Thinking that the reading that ADO performs is sequential and when it finds a field greater than 256, it begins reading the next field in the next bit of the file and for this reason it is truncated, I have decided to take the solution of placing the fields greater than 256 at the end of the table, in this way the information returned is correct since when it finds the end of the line the reading position is reset to the next record. It is not a 100% correct solution but it works for me, since normally I will not use fields greater than 256 for the SQL queries that I will perform with ADO.
--------

驴 Y porque no ?

驴 And why not ?
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW_DbfSqlQuery con campos mayores de 256 carracteres
Posted: Fri Mar 08, 2024 06:51 PM

This is a great discovery

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion