none
Adding a datarow to a datatable RRS feed

  • Question

  •  

    Hi

     

    I know this is simple because i have done it before!!!!  its just been a while i guess.

     

    basically i want to create a ratarow, then add it to a datatable.  but when i try, it says that "the object is not set to an instance".  Now i tried to put "public Datarow dr = new Datarow();" but it says then that datarow is inaccessible due to its protection level Tongue Tied  Ive declared it as public.

     

    Thanks,

    Mark

    Friday, August 24, 2007 8:11 AM

All replies

  • FYI.

    DataTable dt = new DataTable();
                dt.Columns.Add("Id");
                dt.Columns.Add("Name");
                DataRow dr = dt.NewRow();
                dr["id"] = 1;
                dr["Name"] = "aaa";

                dt.Rows.Add(dr);

    Friday, August 24, 2007 9:01 AM