views:

110

answers:

1

hi

I thought I can fill a typed dataset , which I created like this:

The name of the table is HouseInformation

In design mode I created a column NameOfHouse and Price.

Is it not possible to fill the columns directly? like...

dsWincObjects dsHouse = new dsWincObjects();
dsHouse.NameOfHouse = "value";

and and...

or option I thought...to instatiate the column

dsWincObjects.HouseInformationDataTable dtHouse = new dsWincObjects.HouseInformationDataTable();

Not Possible to acces directly the columns? and give my values to fill?

dtHouse.NameOfHouse = "value";....

Thanks

// edit

dsWincObjects dsMieter = new dsWincObjects();
            dsWincObjects.MieterInformationDataTable dtMieter = new dsWincObjects.MieterInformationDataTable();

            dsWincObjects.MieterInformationRow newRow = dtMieter.NewMieterInformationRow();
            newRow.FullName = "test";
            dsMieter.MieterInformation.AddMieterInformationRow(newRow);
+2  A: 

You need to go row by row and add the information to the columns for each for.

DataTable HouseInformation = new DataTable("HouseInformation");
DataColumn colName = HouseInformation.Columns.Add("NameOfHouse");
DataColumn colPrice = HouseInformation.Columns.Add("Price");

// Add Data
DataRow newRow = HouseInformation.NewRow();
newRow[colName] = "Name of House 1";
newRow[colPrice] = 400000;
HouseInformation.Rows.Add(newRow);
Yaakov Ellis
ok thx but we created your code in design mode.. right?and should be logical to get the columns by intellisense..
snarebold
Columns aren't going to be in there through intellisense (you would get that if you used LinqToSql, EntityFramework or some other ORM). In the code. you can access the columns by reference to the DataColumn (as above), the column index or the column name. Check out the overrides for the newRow[] setting.
Yaakov Ellis
ok thx but see my edits.. i found a reference after searching quarter hour.. thats a bit cleaner right?
snarebold
i'm sorry now for German words.. it's now copied from my project and am Swiss
snarebold