Home All Groups Group Topic Archive Search About
Author
15 Mar 2006 12:16 PM
Joe
Dear all,

I get a result from the sql server and return a dataset
after i get the dataset, i want to add a column to the dataset
the column is boolean and all rows are true, how to do that

Author
15 Mar 2006 1:02 PM
Cor Ligthert [MVP]
Joe,

You never can add a column to a dataset. A dataset is a wrapper which hold
relations and datatables.

You can add a column to a datatable. In visual basic by instance as

ds.tables(0).columns.Add("myColumn",gettype(system.boolean))

I hope this hellps,

Cor

Show quote
"Joe" <J**@discussions.microsoft.com> schreef in bericht
news:5EDDD221-6518-4ACB-87FA-2613FFAFFF26@microsoft.com...
> Dear all,
>
> I get a result from the sql server and return a dataset
> after i get the dataset, i want to add a column to the dataset
> the column is boolean and all rows are true, how to do that
Author
15 Mar 2006 3:45 PM
W.G. Ryan - MVP
Joe, you just need to instantiate a new DataColumn of type Boolean and then
set its DefaultValue property to true and then add it to the table's Columns
collection.  The code below essentially illustrates each item for you:

DataTable dt = new DataTable("DemoTable");

//DataAdapter.Fill(dt);  //Call your Fill method here and get a dataset or
datatable back.

DataColumn BoolColumn = new DataColumn("BoolColumn",
typeof(System.Boolean));

BoolColumn.DefaultValue = true;

dt.Columns.Add(BoolColumn);

Show quote
"Joe" <J**@discussions.microsoft.com> wrote in message
news:5EDDD221-6518-4ACB-87FA-2613FFAFFF26@microsoft.com...
> Dear all,
>
> I get a result from the sql server and return a dataset
> after i get the dataset, i want to add a column to the dataset
> the column is boolean and all rows are true, how to do that

AddThis Social Bookmark Button