Moving into and Processing a second dataset

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

Guest

I am pulling data from a sql server database into a DataSet (or I can pull it
into a SqlDataReader, but for what I want to do I assume the DataSet will
work best). I need to cycle through one of the columns, applying
Server.UrlEncode onto to every row.
Does anyone have any ideas on how easiest to do this? I thought perhaps I
might start out with a SqlDataReader and iterate through it, appending each
row into a DataSet, but before I start the learning curve I thought Id see if
someone has some better, easier ways.
Thanks, Mark
 
I think it's probably easiest w/ a Dataset..

foreach(DataRowName dro in DataSetName.TableName){
dro[ColumnIndex] = UrlEncode(dro[ColumnIndex].ToString());

}
 
Mark,

I assume that you're asking how to iterate through the rows in your DataSet?
I usually do something like this:

DataRow row;
for (int i=0; i < MyDataSet.Tables["MyTable"].Rows.Count; i++)
{
row = MyDataSet.Tables["MyTable"].Rows;
// do whatever you need to do to row["MyColumn"] I don't
// know the correct syntax for that Server.UrlEncode that you want to do
}

Is that what you wanted?

~~Bonnie
 
Back
Top