We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Save/Open diagram from SQLServer ''image'' type field

Thread ID:

Created:

Updated:

Platform:

Replies:

41034 Feb 20,2006 09:51 PM Feb 22,2006 03:32 PM Windows Forms 1
loading
Tags: Diagram
Lan Mo
Asked On February 20, 2006 09:51 PM

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

Lan Mo
Replied On February 22, 2006 03:32 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;