Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

SQLDataSet/ADODataSet

Has anyone found a property(s) which will tell you the actual size of a field
in a DataSet (Mainly, I'm looking for a the max length of a VarChar here,
although precision and scale for numerics will be needed also). These are
properties in ADO.Fields.Field, but I'm looking for an equivalent in .NET.
I found the internal class SQLMetaData using WinCV, but have not found a
way to get at this data. It must be available as the AutoGenerate stuff
uses it after calling SET FORMAT ON;your select to goes here to create parameters.
[564 byte] By [Steve Dee] at [2007-11-9 18:22:33]
# 1 Re: SQLDataSet/ADODataSet
I am somewhat reluctant to reply on this because I am not yet 100% sure
of my answers, but no-one else seems to be answering, so...

I am pretty sure that there is no notion of data sources or db types
(like varchar) in the DataSet object. The fields in a DataSet are based on
the core data types of the CLR (integers, longs, strings, etc...). It is
the responsibility of objects like the SQLDataSetCommand and
ADODataSetCommand to "map" the data back and forth between the data source
(database, etc.) and the DataSet.

One possibility of determining data source schema is to use the
SchemaTable property of the *DataReader objects.

Hope that helps.

Regards,
Dan

"Steve Dee" <Steve_Dee@md.prestige.net> wrote in message
news:39da83d0$1@news.dev-archive.com...
>
> Has anyone found a property(s) which will tell you the actual size of a
field
> in a DataSet (Mainly, I'm looking for a the max length of a VarChar here,
> although precision and scale for numerics will be needed also). These are
> properties in ADO.Fields.Field, but I'm looking for an equivalent in .NET.
> I found the internal class SQLMetaData using WinCV, but have not found a
> way to get at this data. It must be available as the AutoGenerate stuff
> uses it after calling SET FORMAT ON;your select to goes here to create
parameters.
>
Daniel Pratt at 2007-11-11 22:27:23 >
# 2 Re: SQLDataSet/ADODataSet
You are right about the no notion of data types. But, I know the information
is there because if you allow SQLDataSet to AutoGenerate an UPDATE statement
you can see that the DataSet sends across a SET FORMAT ON; to SQL Server
to get the Schema. It then uses this data to build parameters. So the data
is there. I think it's silly to build parameters and "hard-code" data types,
lengths...especially when the data is available (somewhere).

"Daniel Pratt" <dprREMOVETHISatt71@hotmail.com> wrote:
> I am somewhat reluctant to reply on this because I am not yet 100% sure
>of my answers, but no-one else seems to be answering, so...
>
> I am pretty sure that there is no notion of data sources or db types
>(like varchar) in the DataSet object. The fields in a DataSet are based
on
>the core data types of the CLR (integers, longs, strings, etc...). It is
>the responsibility of objects like the SQLDataSetCommand and
>ADODataSetCommand to "map" the data back and forth between the data source
>(database, etc.) and the DataSet.
>
> One possibility of determining data source schema is to use the
>SchemaTable property of the *DataReader objects.
>
> Hope that helps.
>
>Regards,
>Dan
>
>"Steve Dee" <Steve_Dee@md.prestige.net> wrote in message
>news:39da83d0$1@news.dev-archive.com...
>>
>> Has anyone found a property(s) which will tell you the actual size of
a
>field
>> in a DataSet (Mainly, I'm looking for a the max length of a VarChar here,
>> although precision and scale for numerics will be needed also). These
are
>> properties in ADO.Fields.Field, but I'm looking for an equivalent in .NET.
>> I found the internal class SQLMetaData using WinCV, but have not found
a
>> way to get at this data. It must be available as the AutoGenerate stuff
>> uses it after calling SET FORMAT ON;your select to goes here to create
>parameters.
>>
>
>
Steve Dee at 2007-11-11 22:28:29 >
# 3 Re: SQLDataSet/ADODataSet
Just to clarify, unless you are using a newer version of the CLR, I
don't think there is a SQLDataSet object. I assume that you are referring to
SQLDataSetCommand, yes?. Also, are you saying that the
SQLDataReader.SchemaTable is not what you need? i.e. what functionality do
you need that SQLDataReader.SchemaTable would not provide?

Regards,
Dan

"Steve Dee" <Steve_Dee@md.prestige.net> wrote in message
news:39db62d8$1@news.dev-archive.com...
>
> You are right about the no notion of data types. But, I know the
information
> is there because if you allow SQLDataSet to AutoGenerate an UPDATE
statement
> you can see that the DataSet sends across a SET FORMAT ON; to SQL Server
> to get the Schema. It then uses this data to build parameters. So the
data
> is there. I think it's silly to build parameters and "hard-code" data
types,
> lengths...especially when the data is available (somewhere).
>
> "Daniel Pratt" <dprREMOVETHISatt71@hotmail.com> wrote...
Daniel Pratt at 2007-11-11 22:29:32 >
# 4 Re: SQLDataSet/ADODataSet
Doh! Yes, I meant SQLDataSetCommand. Sorry about that. As far as SQLDataReader.SchemaTable...that
will probably give me exactly what I'm looking for. Seems a bit of an odd
way to get it is all. But everything is new, so that's fine! Thanks for
the help.
Steve Dee at 2007-11-11 22:30:32 >