Home All Groups Group Topic Archive Search About
Author
9 Jun 2006 9:08 AM
Micke 2.0
Sorry about the crosspost; not sure in which it belongs.

I tried making a simple UDT comprising of a few integers that are closely
related, and the user designed type seemed perfect (using visual studio
2005). Easily made and easily installed, and from T-SQL it works as
expected.

However .. I fail to be able to use this UDT from within the environment? In
order to use the data, I usually create a dataset and work with that, but
the dataset designed doesn't support UDT. If the designed - which creates
the datarow classes and so on - isn't able to handle UDT's, how would you go
about using this from within for example C#?

foreach (CustomerRow row in ds.Customers) {
  // How would I use an UDT field here?
}


Micke Andersson, Sweden.

Author
9 Jun 2006 10:14 AM
Niels Berglund
Micke 2.0 wrote:
Show quote
> Sorry about the crosspost; not sure in which it belongs.
>
> I tried making a simple UDT comprising of a few integers that are closely
> related, and the user designed type seemed perfect (using visual studio
> 2005). Easily made and easily installed, and from T-SQL it works as
> expected.
>
> However .. I fail to be able to use this UDT from within the environment? In
> order to use the data, I usually create a dataset and work with that, but
> the dataset designed doesn't support UDT. If the designed - which creates
> the datarow classes and so on - isn't able to handle UDT's, how would you go
> about using this from within for example C#?
>
> foreach (CustomerRow row in ds.Customers) {
>   // How would I use an UDT field here?
> }
>
>
> Micke Andersson, Sweden.

In order to use the UDT on the client, it has to be available locally.
So, I have a UDT called Point, and I have retrieved a data reader which
contains a field of the Point type. To work with the UDT I'd do
something like this:

while(dr.Read()) {
   Point p = (Point)dr[1];
   //work with the UDT
}

Hope this helps

Niels
--
**************************************************
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb at develop dot com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
**************************************************
Author
9 Jun 2006 11:53 AM
Mikael Andersson
> In order to use the UDT on the client, it has to be available locally. So,
> I have a UDT called Point, and I have retrieved a data reader which
> contains a field of the Point type. To work with the UDT I'd do something
> like this:
>
> while(dr.Read()) {
>   Point p = (Point)dr[1];
>   //work with the UDT
> }

Hmm .. ok. So in a complex databound scenario, say a rather large vs2005 GUI
project, there *is* no point, then .. you can't databind against it, since
the designer doesn't understand it, and thus you cannot generate typed
datasets for it, which means .. that there's no point, really. :( Even if I
could generate and use a UDT in a table, I could never use that table from a
databound GUI - anywhere.

Maybe the next generation of visual studio completes the idea - creating a
field of type Point shouldn't really be all that hard, but then again, the
dataset designer doesn't even understand Nullable afaik, even though that
would seem an obvious thing to implement.

Thanks for the help anyway - back to the drawing board for me.
/Micke
Author
9 Jun 2006 1:12 PM
ML
I may be completely off here, but I think you could find the XML data type
useful here (with an appropriate XML Schema), rather than re-inventing the
wheel with the UDT.


ML

---
http://milambda.blogspot.com/
Author
9 Jun 2006 3:06 PM
David Browne
Show quote
"Mikael Andersson" <iptrix@nogmailspam.com> wrote in message
news:uk5qet7iGHA.4304@TK2MSFTNGP03.phx.gbl...
>> In order to use the UDT on the client, it has to be available locally.
>> So, I have a UDT called Point, and I have retrieved a data reader which
>> contains a field of the Point type. To work with the UDT I'd do something
>> like this:
>>
>> while(dr.Read()) {
>>   Point p = (Point)dr[1];
>>   //work with the UDT
>> }
>
> Hmm .. ok. So in a complex databound scenario, say a rather large vs2005
> GUI project, there *is* no point, then .. you can't databind against it,

Sure you can.  Read the data into a List<Point>, or List<MyType> and
databind it.  But no, DataSets don't understand UDT's.

>since the designer doesn't understand it, and thus you cannot generate
>typed datasets for it, which means .. that there's no point, really. :(
>Even if I could generate and use a UDT in a table, I could never use that
>table from a databound GUI - anywhere.
>
> Maybe the next generation of visual studio completes the idea - creating a
> field of type Point shouldn't really be all that hard, but then again, the
> dataset designer doesn't even understand Nullable afaik, even though that
> would seem an obvious thing to implement.
>

I agree, both UDT's and Nullable types are poorly supported in DataSets.
But you no longer have to rely on DataSets for databinding the UI.  Object
collections work quite well now.


David
Author
28 Jun 2006 7:34 PM
bruce barker (sqlwork.com)
but its trivial to inherit from the wizard generated typed dataset and add
support. you could also just edit the generated class file.

-- bruce (sqlwork.com)

Show quote
"Mikael Andersson" <iptrix@nogmailspam.com> wrote in message
news:uk5qet7iGHA.4304@TK2MSFTNGP03.phx.gbl...
>> In order to use the UDT on the client, it has to be available locally.
>> So, I have a UDT called Point, and I have retrieved a data reader which
>> contains a field of the Point type. To work with the UDT I'd do something
>> like this:
>>
>> while(dr.Read()) {
>>   Point p = (Point)dr[1];
>>   //work with the UDT
>> }
>
> Hmm .. ok. So in a complex databound scenario, say a rather large vs2005
> GUI project, there *is* no point, then .. you can't databind against it,
> since the designer doesn't understand it, and thus you cannot generate
> typed datasets for it, which means .. that there's no point, really. :(
> Even if I could generate and use a UDT in a table, I could never use that
> table from a databound GUI - anywhere.
>
> Maybe the next generation of visual studio completes the idea - creating a
> field of type Point shouldn't really be all that hard, but then again, the
> dataset designer doesn't even understand Nullable afaik, even though that
> would seem an obvious thing to implement.
>
> Thanks for the help anyway - back to the drawing board for me.
> /Micke
>
>
Author
9 Jun 2006 11:51 AM
Dan Guzman
To add to Neil's response, the assembly needs to be available to the client
so that the underlying data can be serialized and desterilized.  You can
find more information in the SQL Server 2005 Books Online
(ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/denet9/html/4b0d876c-8066-490e-8e18-327c0e942b19.htm).

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Micke 2.0" <micke@NOekcim.SPAMnet> wrote in message
news:eXcMPR6iGHA.1208@TK2MSFTNGP02.phx.gbl...
> Sorry about the crosspost; not sure in which it belongs.
>
> I tried making a simple UDT comprising of a few integers that are closely
> related, and the user designed type seemed perfect (using visual studio
> 2005). Easily made and easily installed, and from T-SQL it works as
> expected.
>
> However .. I fail to be able to use this UDT from within the environment?
> In order to use the data, I usually create a dataset and work with that,
> but the dataset designed doesn't support UDT. If the designed - which
> creates the datarow classes and so on - isn't able to handle UDT's, how
> would you go about using this from within for example C#?
>
> foreach (CustomerRow row in ds.Customers) {
>  // How would I use an UDT field here?
> }
>
>
> Micke Andersson, Sweden.
>
>
Author
9 Jun 2006 12:02 PM
Mikael Andersson
"Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> wrote in message
news:uhyTes7iGHA.1940@TK2MSFTNGP02.phx.gbl...
> To add to Neil's response, the assembly needs to be available to the
> client so that the underlying data can be serialized and desterilized.
> You can find more information in the SQL Server 2005 Books Online
> (ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/denet9/html/4b0d876c-8066-490e-8e18-327c0e942b19.htm).
>
> --
> Hope this helps.

Thanks. I'd already included the assembly in the GUI project, of course, but
then I found out that the designer choked on UDT's, and that with VS2005 I
found no other reasonable way to do databinding than to use datasets, which
can't be used with UDT's - definitions or no definitions included.

Yes it works with datareaders, but that's of little real use in my projects
anyway, so I'll do things The Old Way for now. Thanks for helping :)

/Micke
Author
9 Jun 2006 12:45 PM
Dan Guzman
The Books Online contains a Dataset/DataAdapter example using UDTs.
However, this isn't a typed dataset which I guess is the VS 2005 designer
issue you are referring to.  Like the SqlDataReader, an cast to the UDT is
required, AFAIK.

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Mikael Andersson" <iptrix@nogmailspam.com> wrote in message
news:%23dDuZy7iGHA.5036@TK2MSFTNGP04.phx.gbl...
>
> "Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> wrote in message
> news:uhyTes7iGHA.1940@TK2MSFTNGP02.phx.gbl...
>> To add to Neil's response, the assembly needs to be available to the
>> client so that the underlying data can be serialized and desterilized.
>> You can find more information in the SQL Server 2005 Books Online
>> (ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/denet9/html/4b0d876c-8066-490e-8e18-327c0e942b19.htm).
>>
>> --
>> Hope this helps.
>
> Thanks. I'd already included the assembly in the GUI project, of course,
> but then I found out that the designer choked on UDT's, and that with
> VS2005 I found no other reasonable way to do databinding than to use
> datasets, which can't be used with UDT's - definitions or no definitions
> included.
>
> Yes it works with datareaders, but that's of little real use in my
> projects anyway, so I'll do things The Old Way for now. Thanks for helping
> :)
>
> /Micke
>
>

AddThis Social Bookmark Button