FW_DbfSqlQuery con campos mayores de 256 carracteres

FW_DbfSqlQuery con campos mayores de 256 carracteres

Postby VictorCasajuana » Tue Mar 05, 2024 9: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: Select all  Expand view
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: Select all  Expand view

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 ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: FW_DbfSqlQuery con campos mayores de 256 carracteres

Postby nageswaragunupudi » Tue Mar 05, 2024 3:01 pm

Please try
VFPOLEDB
oledb for foxpro
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_DbfSqlQuery con campos mayores de 256 carracteres

Postby VictorCasajuana » Fri Mar 08, 2024 2: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: Select all  Expand view
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 ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: FW_DbfSqlQuery con campos mayores de 256 carracteres

Postby nageswaragunupudi » Fri Mar 08, 2024 6:51 pm

This is a great discovery
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests