How do you get the number of columns in a dataset?

I know that I can get the number of rows by:
DataSetObj.Tables(0).Rows.Count.

Also, how do I get the name of the column. I can get to the data by name

DataSetObj.Tables(0).Rows(ktr).Item("Name")

Is there a way to find out what the of a column(item) is if you don't know
it?

Thanks,

Tom

RE: How to get Number of columns in a dataset by BradRoberts56nojunk

BradRoberts56nojunk
Wed Aug 31 15:33:06 CDT 2005

The Rows collection contains Row objects which contain Fields collections
which contain Field objects.


"tshad" wrote:

> How do you get the number of columns in a dataset?
>
> I know that I can get the number of rows by:
> DataSetObj.Tables(0).Rows.Count.
>
> Also, how do I get the name of the column. I can get to the data by name
>
> DataSetObj.Tables(0).Rows(ktr).Item("Name")
>
> Is there a way to find out what the of a column(item) is if you don't know
> it?
>
> Thanks,
>
> Tom
>
>
>

Re: How to get Number of columns in a dataset by Marina

Marina
Wed Aug 31 15:35:39 CDT 2005

count:
myDataSet.Tables(0).Columns.Count

column name:
myDataSet.Tables(0).Columns(colIndex).ColumnName


"tshad" <tscheiderich@ftsolutions.com> wrote in message
news:eXJsPkmrFHA.4072@TK2MSFTNGP09.phx.gbl...
> How do you get the number of columns in a dataset?
>
> I know that I can get the number of rows by:
> DataSetObj.Tables(0).Rows.Count.
>
> Also, how do I get the name of the column. I can get to the data by name
>
> DataSetObj.Tables(0).Rows(ktr).Item("Name")
>
> Is there a way to find out what the of a column(item) is if you don't know
> it?
>
> Thanks,
>
> Tom
>



Re: How to get Number of columns in a dataset by tshad

tshad
Wed Aug 31 16:46:28 CDT 2005

"Marina" <someone@nospam.com> wrote in message
news:%23I9iLumrFHA.3788@TK2MSFTNGP12.phx.gbl...
> count:
> myDataSet.Tables(0).Columns.Count
>
> column name:
> myDataSet.Tables(0).Columns(colIndex).ColumnName

That was what I was looking for.

Thanks,

Tom
>
>
> "tshad" <tscheiderich@ftsolutions.com> wrote in message
> news:eXJsPkmrFHA.4072@TK2MSFTNGP09.phx.gbl...
>> How do you get the number of columns in a dataset?
>>
>> I know that I can get the number of rows by:
>> DataSetObj.Tables(0).Rows.Count.
>>
>> Also, how do I get the name of the column. I can get to the data by name
>>
>> DataSetObj.Tables(0).Rows(ktr).Item("Name")
>>
>> Is there a way to find out what the of a column(item) is if you don't
>> know it?
>>
>> Thanks,
>>
>> Tom
>>
>
>



Re: How to get Number of columns in a dataset by Cor

Cor
Thu Sep 01 02:20:34 CDT 2005

Thad,

Just for the record, don't mix up a dataset with a recordset.

A dataset contains no columns. The only items it has are datatables,
relations, keys etc. about that.

Just as addition.

Cor



Re: How to get Number of columns in a dataset by tshad

tshad
Thu Sep 01 10:12:52 CDT 2005

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:eYWePXsrFHA.3264@TK2MSFTNGP12.phx.gbl...
> Thad,
>
> Just for the record, don't mix up a dataset with a recordset.
>
> A dataset contains no columns. The only items it has are datatables,
> relations, keys etc. about that.

That may be true but you use "Columns" to find the names and number of
"Columns" in the Dataset - don't you?

As Marina pointed out:

count:
myDataSet.Tables(0).Columns.Count

column name:
myDataSet.Tables(0).Columns(colIndex).ColumnName

Thanks,

Tom
>
> Just as addition.
>
> Cor
>



Re: How to get Number of columns in a dataset by Marina

Marina
Thu Sep 01 10:30:16 CDT 2005

My example was for getting the columns from the first table in a dataset.

Cor was correctin that a dataset is just a collection of tables. It has no
columns as such.

If you were talking about a database for example, you wouldn't say that a
database has column. A database has tables. And those tables are the things
that have columns.

Same idea here.

"tshad" <tscheiderich@ftsolutions.com> wrote in message
news:%23c%23VfewrFHA.3060@TK2MSFTNGP09.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:eYWePXsrFHA.3264@TK2MSFTNGP12.phx.gbl...
>> Thad,
>>
>> Just for the record, don't mix up a dataset with a recordset.
>>
>> A dataset contains no columns. The only items it has are datatables,
>> relations, keys etc. about that.
>
> That may be true but you use "Columns" to find the names and number of
> "Columns" in the Dataset - don't you?
>
> As Marina pointed out:
>
> count:
> myDataSet.Tables(0).Columns.Count
>
> column name:
> myDataSet.Tables(0).Columns(colIndex).ColumnName
>
> Thanks,
>
> Tom
>>
>> Just as addition.
>>
>> Cor
>>
>
>



Re: How to get Number of columns in a dataset by tshad

tshad
Thu Sep 01 10:30:43 CDT 2005

"tshad" <tscheiderich@ftsolutions.com> wrote in message
news:%23c%23VfewrFHA.3060@TK2MSFTNGP09.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:eYWePXsrFHA.3264@TK2MSFTNGP12.phx.gbl...
>> Thad,
>>
>> Just for the record, don't mix up a dataset with a recordset.
>>
>> A dataset contains no columns. The only items it has are datatables,
>> relations, keys etc. about that.
>
> That may be true but you use "Columns" to find the names and number of
> "Columns" in the Dataset - don't you?
>
> As Marina pointed out:
>
> count:
> myDataSet.Tables(0).Columns.Count
>
> column name:
> myDataSet.Tables(0).Columns(colIndex).ColumnName

Also, you add columns using "New DataColumn". I'm not sure why you have
both columns and itemarrays.

Tom

>
> Thanks,
>
> Tom
>>
>> Just as addition.
>>
>> Cor
>>
>
>



Re: How to get Number of columns in a dataset by tshad

tshad
Thu Sep 01 11:18:16 CDT 2005

"Marina" <someone@nospam.com> wrote in message
news:uCVFLowrFHA.4040@TK2MSFTNGP14.phx.gbl...
> My example was for getting the columns from the first table in a dataset.
>
> Cor was correctin that a dataset is just a collection of tables. It has
> no columns as such.
>
> If you were talking about a database for example, you wouldn't say that a
> database has column. A database has tables. And those tables are the
> things that have columns.
>
> Same idea here.

That makes sense.

The Dataset is a level above DataTables.

Thanks,

Tom
>
> "tshad" <tscheiderich@ftsolutions.com> wrote in message
> news:%23c%23VfewrFHA.3060@TK2MSFTNGP09.phx.gbl...
>> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
>> news:eYWePXsrFHA.3264@TK2MSFTNGP12.phx.gbl...
>>> Thad,
>>>
>>> Just for the record, don't mix up a dataset with a recordset.
>>>
>>> A dataset contains no columns. The only items it has are datatables,
>>> relations, keys etc. about that.
>>
>> That may be true but you use "Columns" to find the names and number of
>> "Columns" in the Dataset - don't you?
>>
>> As Marina pointed out:
>>
>> count:
>> myDataSet.Tables(0).Columns.Count
>>
>> column name:
>> myDataSet.Tables(0).Columns(colIndex).ColumnName
>>
>> Thanks,
>>
>> Tom
>>>
>>> Just as addition.
>>>
>>> Cor
>>>
>>
>>
>
>