Hello,
I was wondering if anyone knows how to get a column name from a dataset
where the column name contains nulls. I am able to get a columns name using
getxml() however columns that have null's do not return the name of the
column in the xml.

Basically I want the dataset to return columns names even if the column
names contain null values.

thanks guys.

Re: Get Column Name from a DataSet by William

William
Fri Jun 18 12:20:54 CDT 2004

DataSet.Tables[TableIndex].Columns[ColumnIndex].ColumnName;

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"C. Antonio" <dainea@hotmail.com> wrote in message
news:ug1dfRVVEHA.2972@TK2MSFTNGP12.phx.gbl...
> Hello,
> I was wondering if anyone knows how to get a column name from a dataset
> where the column name contains nulls. I am able to get a columns name
using
> getxml() however columns that have null's do not return the name of the
> column in the xml.
>
> Basically I want the dataset to return columns names even if the column
> names contain null values.
>
> thanks guys.
>
>



Re: Get Column Name from a DataSet by C

C
Fri Jun 18 13:18:48 CDT 2004

Thanks for the quick response Ryan, however this is what is happening:

There are two situation:

1.---- When table does not have any rows, the dataset.getxml() does not
return any column names This is what we are doing like you had in the first
scenario:

DataSet.Tables[TableIndex].Columns[ColumnIndex].ColumnName;



2. -- When the table has rows in it, the dataset.getxml() returns only
columns which has data.

In this scenario we are running two loops to get the column names

Here is what we are doing in the second scenario

for (int lrow = 0; lrow <= ds.Tables[0].Rows.Count - 1; lrow++) {

for (int lcol = 0 ; lcol <= ds.Tables[0].Columns.Count - 1; lcol++)

{

colname = ds.Tables[0].Columns[lcol].ColumnName;

colvalue= ds.Tables[0].Rows[lrow][colname].ToString();

}

}

Is there a single way of doing both scenarios?

"William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
news:#5MUejVVEHA.3428@TK2MSFTNGP12.phx.gbl...
> DataSet.Tables[TableIndex].Columns[ColumnIndex].ColumnName;
>
> --
> W.G. Ryan MVP Windows - Embedded
>
> http://forums.devbuzz.com
> http://www.knowdotnet.com/dataaccess.html
> http://www.msmvps.com/williamryan/
> "C. Antonio" <dainea@hotmail.com> wrote in message
> news:ug1dfRVVEHA.2972@TK2MSFTNGP12.phx.gbl...
> > Hello,
> > I was wondering if anyone knows how to get a column name from a dataset
> > where the column name contains nulls. I am able to get a columns name
> using
> > getxml() however columns that have null's do not return the name of the
> > column in the xml.
> >
> > Basically I want the dataset to return columns names even if the column
> > names contain null values.
> >
> > thanks guys.
> >
> >
>
>