Querying More Than 255 Characters from FoxPro/DBase Database Field

M

Matt Young

I've been tasked with integrating an older management system based on
DBF files with my snappy new ASP application to provide users of the
ASP application with real-time data from the management system.

I figure with DBF files, I should use either the DBase drivers or the
FoxPro drivers to connect to the database.

The integration has gone quite smoothly until yesterday. This means
that my connection strings work well based on the DBase drivers, and I
have been able to query data successfully.

What changed yesterday is that a field from the management system has
grown beyond 255 characters. It seems there is a limitation somewhere
with the connection object. The management system handles the large
field just fine. But when I try to query the very same field in my
ASP application via my DBase-based connection object, it returns a
truncated result at the 254th character (too close to 255 characters
for a max varchar field size that I am accustomed to in SQL server).

The data in the DBF is indeed not truncated. Only the result from my
SQL statement is. Switching to the FoxPro driver does not change
this.

Can anyone help me modify the following code so that it converts the
field type to, say, MEMO, so that the queried results are not
truncated? Or perhaps I'm barking up the wrong tree and someone can
tell me where else I've gone wrong. This is just the way I'm working
with the cards I've been dealt.

Thanks,
Matt

---------------------------

Set dbfConn = Server.CreateObject("ADODB.Connection")
'The DBase Connection String
dbfConn.Open "Driver={Microsoft dBASE Driver "_
& "(*.dbf)};DriverID=277;Dbq=C:\ManagementSys\Data\;"

'The Visual FoxPro Connection String
'dbfConn.Open "Driver=Microsoft Visual FoxPro " _
'& "Driver;SourceType=DBF;SourceDB=C:\ManagementSys\Data\;"_
'& "BackgroundFetch=no;"

Set dbfRS = Server.CreateObject("ADODB.Recordset")

sql = "SELECT fieldX FROM tableY WHERE recordID = 1234"
dbfRS.Open sql, dbfConn
 
M

Matt Young

Aaron,

Thanks for the pointer. I've tried what you suggested without any
luck. The following code returns the exact same result:

---------------------------
Set dbfConn = Server.CreateObject("ADODB.Connection")
'The DBase Connection String
dbfConn.Open "Driver={Microsoft dBASE Driver "_
& "(*.dbf)};DriverID=277;Dbq=C:\ManagementSys\Data\;"

'The Visual FoxPro Connection String
'dbfConn.Open "Driver=Microsoft Visual FoxPro " _
'& "Driver;SourceType=DBF;SourceDB=C:\ManagementSys\Data\;"_
'& "BackgroundFetch=no;"

sql = "SELECT fieldX FROM tableY WHERE recordID = 1234"
dbfConn.Execute(sql)
---------------------------

Both the dBase and FoxPro drivers provide the same result.

BUT, there is new information I was not aware of. I was provided with
a text file which describes the different fields I'm working with
here. The particular field I am trying to query is of type ARRAY.

So, if I open up the DBF in notepad, the field appears as one long
string. But if you break it down, each element in the string
represents three pieces of information: a date and two
single-character codes for a total of ten characters. For example:

mmddyyyyax

Where a and x are the single character codes respectively. As more
elements are added to the field, in notepad it begins to look like
this:

mmddyyyyaxmmddyyyyaxmmddyyyyaxmmddyyyyaxmmddyyyyaxmmddyyyyax

This has not been a problem until the field got beyond 255 characters.
I'm not sure if it's this ARRAY typing that is causing the issue.

I'd love more suggestions.

Matt
 
A

Aaron Bertrand [MVP]

sql = "SELECT fieldX FROM tableY WHERE recordID = 1234"
dbfConn.Execute(sql)

What do you expect to happen here? You haven't assigned the results to
anything, you told the database to execute a SELECT statement, and it
probably did that no problem, but didn't send results anywhere because you
didn't tell it to...
mmddyyyyax

Where a and x are the single character codes respectively. As more
elements are added to the field, in notepad it begins to look like
this:

mmddyyyyaxmmddyyyyaxmmddyyyyaxmmddyyyyaxmmddyyyyaxmmddyyyyax

Sorry, I know nothing about DBF's file format. This seems to be a FoxPro
issue, not an ASP one, so my only suggestion is to post your issue to a
FoxPro group.
 
G

Garrett Fitzgerald

BUT, there is new information I was not aware of. I was provided with
a text file which describes the different fields I'm working with
here. The particular field I am trying to query is of type ARRAY.

VFP doesn't support an array field type.

Also, have you tried downloading the VFP OLE DB provider from
<http://www.microsoft.com/downloads/...58-7a94-4ae1-a59e-965869cb3bc9&displaylang=en>?

Using the ODBC driver requires that you do something with GetChunk() which,
fortunately, I've never needed to do. :) The OLE DB provider _might_
avoid this.

Garrett Fitzgerald
MailMovers
Seattle, WA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top