Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Need expert help and advice. Thank you.

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-02-27 : 08:32:14
Hello,

I am using Enterprise Library Data Access and SQL 2005 application block and I need to know if it is possible to do the following:

Consider I have a String:

Dim MyString As String = "Hello"

or an Integer:

Dim MyInteger As Integer = 100

or a class which its properties:

Dim MyClass As New MyCustomClass
MyClass.Property1 = "Hello"
MyClass.Property2 = Unit.Pixel(100)
MyClass.Property3 = 100

Or even a control:

Dim MyLabel As Label
MyLabel.Id = "MyLabel"
MyLabel.CssClass = "MyLabelCssClass"

Is there a way to save a String, an Integer, a Boolean, a Class, a Control in an SQL database?

Something like:

Define something (Integer, String, Class, Control, etc)

Save in SQL 2005 Database

Later in code Retrive from database given its ID

Is this possible?

How should I do this?

What type of SQL 2005 table field should be used to store the information?

Thanks,
Miguel

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-27 : 09:46:58
you can do that with a dataset and it's update method

what do you want exactly?
save settings?


Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-02-27 : 09:58:03
Basically,

I need to know:

1. What should the data type of the SQL 2005 table column which will hold the objects (It can be a string, an integer, a class, a control, a boolean, etc)

2. In .NET code how can I "prepare" my object before send it to the database. What should be the .NET type?
I suppose I need to convert my object (String, Class, Control, ...) to some kind of SQL object type?

By the way I am working with Enterprise Library Data Access Application Block.

This is not as straight forward as using a dataset.

Anyone?

Thanks,
Miguel
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-02-28 : 10:37:35
You can do it one of two ways, either create a CLR User-defined Type, see
http://msdn2.microsoft.com/en-us/library/ms131120.aspx
http://msdn2.microsoft.com/en-us/library/ms186366.aspx
http://msdn2.microsoft.com/en-us/library/ms160738.aspx

or you can serialize your object and store the serialized data in the database and deserialize when you read it. In this case you can store that data in a varbinary column or an xml column depending on which formatter you use to preform the serilaization. See
http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.aspx
Go to Top of Page

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-02-28 : 10:46:41
quote:
Originally posted by snSQL

or you can serialize your object and store the serialized data in the database and deserialize when you read it. In this case you can store that data in a varbinary column or an xml column depending on which formatter you use to preform the serilaization. See
http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.aspx




I think I am going this way using binary serialization.

Thank You for your help,
Miguel
Go to Top of Page
   

- Advertisement -