Retreiving TChart from an OLE\Long Binary field from Access

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
2DScatterPlot
Newbie
Newbie
Posts: 5
Joined: Thu Sep 23, 2004 4:00 am
Location: Australia

Retreiving TChart from an OLE\Long Binary field from Access

Post by 2DScatterPlot » Fri May 27, 2005 1:55 am

Hi Newsgroup,

I've constructed an application that creates hundreds of charts. Each chart is stored in an OLE\Long Binary field in MS Access 2003 (Jet 40 Database actually).

I'm able to insert the charts as such;

System.IO.MemoryStream _graph = new System.IO.MemoryStream();
this.tcmap.Export.Template.Save(_graph);

byte[] mapbuffer = this._graph.GetBuffer();
//Then perform the insert.

Question, how do I retrieve the graph from the OLE\Long Binary field into an object varible of some sort to be placed onto the windows form with the TeeChart assembly on it? To do the reverse of the above isn't quite apparent.

Using C# 2003, OleDb namespace and Access 2003 backend.

Many Thanks NewsGroup.

Regards,
2DScatterPlot. 8)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri May 27, 2005 7:37 am

Hi 2DScatterPlot,

You could have a look at the TeeChart tutorials, available at the TeeChart program group, specially number 8: "ADO.NET Database Access".
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

2DScatterPlot
Newbie
Newbie
Posts: 5
Joined: Thu Sep 23, 2004 4:00 am
Location: Australia

Post by 2DScatterPlot » Mon May 30, 2005 1:35 am

Hello narcis,

Thanks for the response. I did indeed look through the tutorials particularly number 8 before posting. I can't find which one, if there is one at all that, contains a TeeChart graph (as .TEN format I assume) as an object contained in an OLE Object\Long Binary field example. The example shows (Tutorial 8) what to do with an existing chart object. I need to retreive the object from the OLE Object\Long Binary field.

I have two layers that deal with accessing the database. These two layers do not reference the TeeChart assemblies, only the User Interface layer does reference this.

I'm having difficultly retreiving the object from the database table (stored as an OLE Object\Long Binary format), and not as chart data the tutorials show. As I've stated I know how to insert and update TCharts by using a System.IO.Memory object variable and byte[] array, but retrieval using object variables seems troublesome for us.

We've tried here to retrieve the field data into a byte[] array and passing the byte[] array to the System.IO.MemoryStream contructor and passing the memory stream to the template Import function. We keep getting an error message that the end of stream has already been reached, hence the chart is not displayed on the winform. An eg. of what we are trying to do here;

byte[] _buffer = new byte[8];
long _getbytes = oledbreadervar.GetBytes(chartobjFieldIndex, 0L, _buffer, 0, _buffer.Length);

_map.Graph = new System.IO.MemoryStream(_buffer);

In the interface layer;

this.tchartOnTheWinForm.Import.Template.Load(_map.Graph);

Causes the error message mentioned. What are we not talking into consideration here?

Thanks for your consideration Newgroup.

Regards,
2DScatterPlot. 8)

2DScatterPlot
Newbie
Newbie
Posts: 5
Joined: Thu Sep 23, 2004 4:00 am
Location: Australia

Post by 2DScatterPlot » Tue May 31, 2005 2:26 am

Hello Narcis, Newsgroup,

I've worked it out, for all that are interested, in order to retreive a .TEN TChart object from an OLE Object\Long Binary Field in MS access, please do the following (via a data reader (OleDb));

byte[] _buffer = (byte[]) oledbreader.GetValue(fieldindex);

System.IO.MemoryStream ioms = new System.IO.MemoryStream(_buffer);

...and way you go it all works.

Narcis, if I may ask you (and all invovled at Steema), is there a better or proper way of doing this? The reason I ask is cause I worked this out (the very hard way) and would be assuring if this is a common or typical way of doing this.

Many thanks Newsgroup.

Regards,
2DScatterPlot.
8) Beyond Good, and
:twisted: Evil

Post Reply