DataTable/DataSet question
- From: "jason" <iaesun@xxxxxxxxx>
- Date: 2 Sep 2005 13:40:29 -0700
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++;
}
}
.
- Follow-Ups:
- Re: DataTable/DataSet question
- From: ErPotenza
- Re: DataTable/DataSet question
- From: Cor Ligthert [MVP]
- Re: DataTable/DataSet question
- Prev by Date: Re: transaction with unknown nbr of commands
- Next by Date: Re: DataTable/DataSet question
- Previous by thread: Re: transaction with unknown nbr of commands
- Next by thread: Re: DataTable/DataSet question
- Index(es):