VFP - SQLEXEC is returning DATE field as CHAR

Asked

Viewed 150 times

1

I am supporting a "legacy" application written in VFP, which uses DBF tables and now migrating to SQL Server.

I created a test table in SQL, which contains fields of some basic types, to be able to work with migration, performing search tests, inclusion, change, etc.

The table has the following format:

CREATE TABLE [dbo].[teste](
  [CpTexto] [varchar](50) NULL,
  [CpData] [datetime] NULL,
  [CpDataTime] [datetime] NULL,
  [CpValor] [numeric](15, 5) NULL,
  [CpInteiro] [int] NULL,
  [ID] [int] IDENTITY(1,1) NOT NULL
  ) ON [PRIMARY]

From VFP I am making queries using SQLEXEC, with the following syntax:

lnNumConex = 1
lnSQL = [SELECT * FROM TESTE]
lnTmpCur = [CurTESTE]
= SQLEXEC(lnNumConex,lnSQL,lnTmpCur)

When I do SQLEXEC, SQL returns a cursor, with all fields contained in the TEST table, but the cpDATA field instead of seeing a field in DATE format, it returns as a CHAR field.

Does anyone know what’s going on?

1 answer

1

I was able to figure out what was wrong.

By default, the SQL connection used the native SQL Server driver installed on the pc

The Connection String was like this:
Driver={SQL Server};Server=XXX;Database=YYY;UID=fulano;PWD=senha;],

and when I started using the most current client I have (client 10.0), everything started working fine.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.