populating a dataset row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

C#

How do I populate a row in a dataset ? I have created a class called Job.
In this class I have a few methods such as CreateJob and FetchJob. FetchJob
returns a DataSet of the Job table. The idea being, when I want to view or
modify a certain Job , I call this method, passing in the unique ID and get
back a dataset with that row in it.

In the Job class though, how do I populate a row with the relevant info? My
first attempt was to find the Job using a SQL stored procedure and then using
a DataReader I could read all the field values. I used the
JobDataSet.Job.AddJobRow() method, which requires a value for each field on
the Job table, but it doesnt ask me for the Key field value (Job.JobObj). Am
I doing this the wrong way? I see there is another method though, which is
simply JobDataSet.Job.NewRow() which doesnt require any params, is this what
I should use?

Thanks

Steve
 
The problem is that you don't appear to be adding the row. If you use
NewRow() then make sure you add that row to the table using
DataTable.Rows.Add(WhateverRowYouJustCreated);
 
Back
Top