VintaSoft Annotation .NET Plug-in Discussions

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Saving and loading annotations (XMP) from database



Saving and loading annotations (XMP) from database

Post by pikob1 »

Hi,

I have this code for loading annotations from database:
            AnnotationCollection collection;
            XmlDocument doc = new XmlDocument();
            cmd.CommandText = "SELECT ... FROM ... WHERE Id=" + id + ";";
            cmd.Connection = con2;
            object obj = cmd.ExecuteScalar();

            doc.InnerXml = obj.ToString();

            collection = annotationViewer1.Annotations[0];
            collection.Load(doc);
and this for saving them:
            XmlDocument doc = annotationViewer1.Annotations[0].Save();
            cmd.CommandText = "UPDATE ... SET ...=@xmldata WHERE Id=" + id + ";";
            SqlParameter sqlparam1 = new SqlParameter("@xmldata", SqlDbType.VarChar);
            sqlparam1.Value = doc.InnerXml;
            cmd.Parameters.Add(sqlparam1);
            cmd.Connection = con2;
            cmd.ExecuteNonQuery(); // dodanie rekordu zdjД™cia
Saving operation is ok.

The problem is with loading annotations from database.
They appear in doc variable and in InnerXml, but collection doesn't load the data nor display saved annotations.

Could anyone help?


Re: Saving and loading annotations (XMP) from database

Post by pikob1 »

Ok, I solved it.

The field in database should be of Xml type.

And saving should use SqlDbType.Ntext type.


Page 1 from 1: 1