DataTable/DataSet question

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



do i have to use a DataTable inside of a DataSet? what exactly is the
difference between them?

i am trying to add a DataRow to a DataTable, then reference that row so
that i can assign values to its columns. however the row addition seems
to be failing, stating that the index is out of range.

all of the examples i've looked up to try to find out more have the
table as part of a dataset. is this a requirement?

jason

(code sample:)

using (SqlConnection oConnection = new SqlConnection(sInfo))
using (SqlCommand oCommand = new SqlCommand(sQuery, oConnection))
{
SqlDataReader oReader = oCommand.ExecuteReadeR();
DataTable oTable = new DataTable();
int nRow = 0;
while(oReader.Read())
{
DataRow oRow = oTable.NewRow();
oTable.Rows[nRow]["field1"] = "value1";
oTable.Rows[nRow]["field2"] = "value2";
nRow++;
}
}

.