473,563 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OLE Object to float array

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
Aug 24 '08 #1
2 2012
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
Aug 25 '08 #2
You are welcome, Peter.
Glad to help.

Regards,
Jialiang Ge
Microsoft Online Community Support

=============== =============== =============== ====
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=============== =============== =============== ====

Aug 26 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2293
by: Dave win | last post by:
Hi all: I'm confused with the expression "(float *())". Book says that this is a cast. But, I have no idea of this expr. why could this expr ignore the variable??? Thanx!!!
11
2253
by: Marc Pelletier | last post by:
Hello, I am having trouble implementing the following callback: CNCSError CECWCompressor::WriteReadLine(UINT32 nNextLine, void **ppInputArray) where ppInputArray is a 3 by x array. The length of x is not known at compile time.
1
18149
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it is serialized correctly, and the server returns a response (I've captured the response and it's correct!) but when the .NET deserialize this...
4
6066
by: viks | last post by:
Hi guys I need little help here . I want to convert 'System::Object __gc * array ' to 'float array' Lets say I have object Reader with method Send ,it returns a variant that contains a one-dimensional array of float value . I m trying to do something like this.
9
30491
by: Gregory.A.Book | last post by:
I am interested in converting sets of 4 bytes to floats in C++. I have a library that reads image data and returns the data as an array of unsigned chars. The image data is stored as 4-byte floats. How can I convert the sets of 4 bytes to floats? Thanks, Greg Book
5
2379
by: xxx | last post by:
Hi all, i'm new in visual c++ and i'm having troubles converting types. Let me explain: i have an unmanaged c++ function that wants an float* parameter but i have an array<float>^, how i can covert it? the following code doesn't show up any error during compile time but crashes at runtime telling "unrecognized or unsupported array type": ...
0
1084
by: Stou Sandalski | last post by:
Hi, I have a python library created by wrapping the C++ library using Boost.Python, the problem is that the wrappers are not very pythonic.... so I want to add some methods that do not exist in the C+ + implementation, that would create a better Python interface. For example to initialize the data in an object in the library one must...
1
1444
by: vipinsoni | last post by:
Hi all, I am stucked with a problem. I have to paas a System.Array of object to my unmanaged C code as a void* I have a class of 'PointZ' which stores x, y,z coordinate and have some methods.I created an System.Array of million of points which contain these point information. I control the size of array on runtime while storing the data into...
14
1817
by: sumsin | last post by:
From 'Inside the C++ Object Model' by 'Stanley B. Lippman' 'The primary strength of the C++ Object Model is its space and runtime efficiency. Its primary drawback is the need to recompile unmodified code that makes use of an object of a class for which there has been an addition, removal, or modification of the nonstatic class data...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.