Saving and loading annotations (XMP) from database

Questions, comments and suggestions concerning VintaSoftAnnotation.NET Plug-in.

Moderator: Alex

Saving and loading annotations (XMP) from database

Postby pikob1 » Thu Mar 25, 2010 4:14 pm

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 11:47 am

Re: Saving and loading annotations (XMP) from database

Postby pikob1 » Fri Mar 26, 2010 10:06 am

Ok, I solved it.

The field in database should be of Xml type.

And saving should use SqlDbType.Ntext type.
pikob1
 
Posts: 4
Joined: Fri Mar 19, 2010 11:47 am


Return to VintaSoftAnnotation.NET Plug-in Discussions

Who is online

Users browsing this forum: No registered users and 0 guests

cron