Hello There,
I have written the code:
private void LoadTreeFromDB()
{
// read diagram data to a byte array from a "IMAGE" field in a SQLServer table.
byte[] buffer=BL.Access.GetTree(mTreeSet,mPaveType,mFuncClass);
// convert the byte array data to a MemoryStream
MemoryStream ms = new MemoryStream();
ms.Write (buffer, 0, buffer.Length);
// Load diagram from the MemoryStream
this.diagram.LoadBinary(ms);
}
private void SaveTreeToDB()
{
// Save diagram to a MemoryStream
MemoryStream oStream= new MemoryStream();
this.diagram.SaveBinary(oStream);
// convert the MemoryStream to a byte array data
byte[] buffer =oStream.ToArray();
// save the byte array data to a "IMAGE" field in a SQLServer table.
BL.Access.SaveTree(mTreeSet,mPaveType,mFuncClass,buffer);
}
it saves the diagram to ''Image'' field without error. but when it read diagram back from the ''Image'' field, it gets error as attached file.
I''hve check the saving/reading byte array data to database ''image'' field, they are working OK.
But when it run this line:
// Load diagram from the MemoryStream
this.diagram.LoadBinary(ms);
The error comes.
Any idea?
Lan
>Hello there,
>I want to save diagram to a table field (Image type) in sql server, then read the diagram from the table ''image type'' field.
>How can I do it? any samples?
>Originally, I save/open diagram to/from files, but now I need save/read them from a table field.
>
>Thanks for any help.
>
>Lan
Error_LoadingDiagram.zip