Question about storing XML in database....

  • Thread starter Thread starter craig
  • Start date Start date
C

craig

Some of the user interface components I am using (Infragistics) are capable
of generating both XML and binary data that represents component
configuration settings as defined by the user. I would like to store this
information in the Database along with other user account information. That
way, if a user logs into a different machine, the system can restore their
user interface configuration settings from the DB.

I am just wondering if there is a way to generate filestreams in memory that
are then written to the DB rather than to files on the hard drive. There
must be a way to do this. Hoping someone can point me in the right
direction!

Thanks!!
 
Craig,

Most databases should be able to store binary fields, as well as XML (if
not for anything else, then as a string). If you don't need to have this
information in a human readable format (since it is the configuration for a
specific component, I would imagine not), I would recommend declaring a
field of variable binary length (image, or a varbinary field which you know
will handle any configuration file), and then serialize to a MemoryStream
(or to a byte array). You can then just set the value in a DataSet (it will
be represented as a byte array) and update the database.

Hope this helps.
 
Thanks to both of you for the responses!! This is exactly the information
that I was looking for.

I really appreciate the help!
Craig


Nicholas Paldino said:
Craig,

Most databases should be able to store binary fields, as well as XML
(if not for anything else, then as a string). If you don't need to have
this information in a human readable format (since it is the configuration
for a specific component, I would imagine not), I would recommend
declaring a field of variable binary length (image, or a varbinary field
which you know will handle any configuration file), and then serialize to
a MemoryStream (or to a byte array). You can then just set the value in a
DataSet (it will be represented as a byte array) and update the database.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

craig said:
Some of the user interface components I am using (Infragistics) are
capable of generating both XML and binary data that represents component
configuration settings as defined by the user. I would like to store
this information in the Database along with other user account
information. That way, if a user logs into a different machine, the
system can restore their user interface configuration settings from the
DB.

I am just wondering if there is a way to generate filestreams in memory
that are then written to the DB rather than to files on the hard drive.
There must be a way to do this. Hoping someone can point me in the right
direction!

Thanks!!
 
Nicholas Paldino said:
Most databases should be able to store binary fields, as well as XML (if
not for anything else, then as a string).

SQL Server 2005 (Yukon) has a new XML datatype, which will show up in VS.NET
2005 (Whidbey) as the .NET XmlReader type when you use the wizards to create
data adapters and typed datasets. The XML type is a first-class type, like
int, that can be queried on, etc.

See for example,
http://www.developer.com/db/article.php/3294151
http://www.winnetmag.com/Article/ArticleID/40482/40482.html
http://dnjonline.com/articles/dbaccess/sep04_yukon_xml.asp
etc.

-- Alan
 
Back
Top