hi,
I want to show in a seperate form the numbers (counter) of records read from a datareader.
I need this to show the progress and the option to cancel/stop the datareader from reading.
I don't know how to do it to get it works....RecordCounterForm is still empty :-(
// Mainform
..
..
RecordCounterForm rc = new RecordCounterForm();
int RecordCount = 0;
rc.ChildText = "Start met tellen";
rc.Show();
while (reader.Read())
{
RecordCount++;
rc.ChildText = RecordCount.ToString();
// if rc.CancelButton then stop
}
..
..
///childform with the counter
namespace Demo
{
public partial class RecordCounterForm : Form
{
public RecordCounterForm()
{
InitializeComponent();
}
public String ChildText
{
get { return txtChildText.Text; }
set { txtChildText.Text = value; }
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
this.Close();
}
private void UpdateText(string ChildText)
{
txtChildText.Text = ChildText;
}
}
}
Loading

Tim ClaasonRank #4,458 · 342 reputationPosted Jan 10, 2011, 10:22 AM EST
Are you really buying yourself anything by allowing cancellation during Reader iteration? You can load a Reader into a DataTable, and use your datatable as a datasource.
Sam HobbsRank #107 · 20.5K reputationPosted Jan 10, 2011, 7:22 PM EST
Mieke3 reputationPosted Jan 11, 2011, 4:34 AM EST
Thanks, I will have a look