I see that this question in various forms has been asked and answered here before, but none of them address my needs...:-(
What I need to do is a simple vb6 or vb.net (or even c#) oleDB read from the foxpro database where the table contains memo fields.
I get data in the field, but its garbage. I suppose I need to get the field contents in another way but have no idea how to..
I have the latest foxpro drives sfrom MS
Any help out there
example code VB6
sConnString = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & sSourceDB & ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO;"
Set oConn = New Connection
oConn.CommandTimeout = 300
oConn.ConnectionTimeout = 5
oConn.CursorLocation = adUseServer
oConn.ConnectionString = sConnString
oConn.Open
Dim oRst As ADODB.Recordset
Set oRst = oConn.Execute("Select * from adm_log")
s = Trim$(oRst(6).GetChunk(oRst(6).ActualSize))
or makes no difference if i do this
s = Trim$(oRst(6))
OR VB.net

Foxpro memo field in ado (or ado.net)
PeteJM01
Your code seems right when you assume the memo content as plain text. However, foxpro memo fields can hold any type of data up to 2Gb. That is, it can hold a binary too (ie: a copy of myimage.jpg just as it be stored on disk). In SQL2000 you can think the only compatible datatype is image.
If you know the content would hold text (ie: notes) then do it like you do. Else get the content as byte[]. Otherwise you not only get 'garbage' but less then what should be there. ie:
while ( olReader.Read )
{
byte[] myMemo = (byte[])olReader["myMemoField"];
// do whatever
}
Data in a memo can be large so a buffered read might be better. Check "Obtaining BLOB Values from a Database" on MSDN help.
NeW2VB
I think you have made it obvious to me that I am making an invalid initial assumption.
No matter what I try and do, including displaying the data in FOXpro (report or form) i Get this:
M a XMEM_CNG_ARR c XMEM_CNG_ARRADM_PRF.LAST_CPER c XMEM_CNG_ARR c XMEM_CNG_ARR6 c XMEM_CNG_ARRADM_PRF.CNG_DATE t XMEM_CNG_ARRki \!﹐BA t XMEM_CNG_ARR c3I 1BA c XMEM_CNG_ARRADM_PRF.CNG_NR n
XMEM_CNG_ARR 1@ n
XMEM_CNG_ARR 2@ a XMEM_PARAM_ARR c XMEM_PARAM_ARR0000000001 c XMEM_PARAM_ARR c ! XMEM_PARAM_ARRdd_mgr.get_table_desc('ADM_PRF') c XMEM_PARAM_ARREVAL n
XMEM_LOG_DESC @”@
The application that is using this field to store text is probably compressing it or something...
Thanks anyway for the help
MMCompton
Wierd that when I dump the physical .fpt file it looks the same in notepad
Danny Tuppeny
Sorry to seem like a dope with this question, and yes you were very clear. Thats why I realised that the application that is using this field is doing something more than just storing text to it. It actually should be plain text, but I think they must be doing something like compressing display text, or enveloping the display text in some kind of object. So basically i'm stuffed because I don't have the application logic, I was hoping that maybe someone would recognise the method of storage and have a suggestion on how to unravel/decrypt/uncompress the text.
litewoheat
Raja Nadar