Saving and loading annotations (XMP) from database

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

Moderator: Alex

Post Reply
pikob1
Posts: 4
Joined: Fri Mar 19, 2010 2:47 pm

Saving and loading annotations (XMP) from database

Post by pikob1 »

Hi,

I have this code for loading annotations from database:

Code: Select all

            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:

Code: Select all

            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?
pikob1
Posts: 4
Joined: Fri Mar 19, 2010 2:47 pm

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.
Post Reply