views:

497

answers:

2

Hi,

I'm writing a C# program to get FoxPro database into datatable everything works except the memo field is blank or some strange character. I'm using C# .Net 2.0. I tried the code posted by Jonathan Demarks dated Jan 12. I am able to get the index but i don't know how to use this index to fetch the data from memo file.

Pleaese help me.

Thanks Madhu

A: 

Have you tried using the FoxPro OLEDB provider? If the database doesn't use features introduced by VFP8 or 9 (notably database events) you could use the ODBC driver as well.

Are these general fields containing documents or images, or text memos or binary memos? What code are you using to extract the data?

Stuart Dunkeld
Hi Stuart,thanQBinary Memos.OleDbConnection Conn = new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=C:\Documents and Settings\All Users\Documents\LSP\LEVEL2.dbf");Conn.Open();Oledbadapter da = new OleDbDataAdapter("Select * From LEVEL2",Conn);da.fill(ds); and i am trying to read each field
Madhu kiran
A: 

I created a function that converts the object returned by the selection to an array of bytes

private byte[] ObjectToByteArray(Object obj) { if (obj == null) return null; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, obj); return ms.ToArray(); }

then you display the value

byte [] dBytes = ConvertObjectToByteArray(dr["profile"]); string str; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); str = enc.GetString(dBytes);

you can now do whatever you want to do with your str