I have tried the following code.
Let me know whether it works for you
-----------------------
database:
C:\OLEToFloatAr ray.mdb
-----------------------
table definiton:
create table tblFloatArray(
FloatArray OLEObject
)
-----------------------
private void button1_Click(o bject sender, EventArgs e)
{
insertIntotblFl oatArray();
float []arr=selectFromt blFloatArray();
}
public void insertIntotblFl oatArray()
{
OleDbCommand cmd = new OleDbCommand("i nsert into tblFloatArray
(FloatArray) values('1.5,3.5 ,6.7,3.2');", new
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\\OLET oFloatArray.mdb "));
cmd.Connection. Open();
cmd.ExecuteNonQ uery();
cmd.Connection. Close();
}
public float[] selectFromtblFl oatArray()
{
float[] retValue = null;
OleDbCommand cmd = new OleDbCommand("s elect FloatArray from
tblFloatArray ", new OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\\OLET oFloatArray.mdb "));
cmd.Connection. Open();
OleDbDataReader dr = cmd.ExecuteRead er();
if (dr.Read())
{
byte[] data = (byte[])dr["FloatArray "];
string temp =
System.Text.Uni codeEncoding.Un icode.GetString (data);
char[]Separator={','} ;
string [] arrStr= temp.Split(Sepa rator);
retValue = new float[arrStr.Length];
int index = 0;
foreach (string str in arrStr)
{
retValue[index++] = float.Parse(str );
}
}
cmd.Connection. Close();
return retValue;
}
"Peter" wrote:
I have OLE Object field in Access Database. This field contains an array of
floats. The array was moved from memory into a string and the string was
saved as OLE Object in a database (That was written in VB6). This data was
used to create graphs, instead creating a record for each point the entire
array was saved in one field.
How do I move the same data from database field in to float array suing C# ?
Thank You
Peter