[Mono-dev] Adding data to a dataset question

tsureshkumar tsureshkumar at novell.com
Wed Aug 10 08:53:42 EDT 2005

Paul F. Johnson wrote:
> Hi,
> I'm trying to add multiple lines to a dataset but keep hitting the same
> problem. Now, I can get around the problem, but I'm not happy with how I have
> to do it.
> 			// create a few rows and add them to the DataTable
> 			DataRow tempRow = dsSource.Tables["sites"].NewRow();
> 			tempRow["url"] = "http://www.gotmono.com";
> 			tempRow["name"] = "Mono community page";
> 			dsSource.Tables["sites"].Rows.Add(tempRow);
> 			tempRow["url"] = "http://www.go-mono.com/tutorial";
> 			tempRow["name"] = "The Mono handbook";
> 			dsSource.Tables["sites"].Rows.Add(tempRow);

you *must* call dsSource.Tables ["sites"].NewRow (), whenever you want 
to add a new row.

if you are tired of repeating them, you can do like this

dsSource.Tables ["sites"].Rows.Add (new object [] 
{"http://www.gotmono.com", "Mono community page" } );
dsSource.Tables ["sites"].Rows.Add (new object [] 
{"http://www.go-mono.com/tutorial", "The Mono handbook" } );

hope that helps.

I think mono-list at lists.ximian.com is the appropriate list for these 
kinda queries.


More information about the Mono-devel-list mailing list