I'm having a little trouble with my application, I have a Database connected and have already displays the values from the first row in the database, however I need to have the database iterate through each row and display them accordingly replacing what was previously there and ideally being delayed by a timer
I thought this was the correct way of going about it however it doesn't seem right as now it doesn't display anything and gives me a System.NullReferenceException. I have tried to solve the issue but seems to be having no luck. If you could recommend something to read, that would be greatly helpful just can't see a lot on the internet for my specific problem
Any help will be great first time posting on here so sorry if things are in the wrong format.
private void FillInTextFields(DataTable table, int ind)
{
foreach(DataRow dr in table.Rows)
{
foreach(var item in dataRow.ItemArray)
{
dataRow = table.Rows[ind];
txtNHSNumber.Text = dataRow.ItemArray.GetValue(0).ToString();
txtFirstName.Text = dataRow.ItemArray.GetValue(1).ToString();
txtLastName.Text = dataRow.ItemArray.GetValue(2).ToString();
txtTimeDate.Text = dataRow.ItemArray.GetValue(3).ToString();
txtHeartRate.Text = dataRow.ItemArray.GetValue(4).ToString();
txtTemp.Text = dataRow.ItemArray.GetValue(5).ToString();
txtReps.Text = dataRow.ItemArray.GetValue(6).ToString();
txtDia.Text = dataRow.ItemArray.GetValue(7).ToString();
txtSys.Text = dataRow.ItemArray.GetValue(8).ToString();
}
}
}
dataRow[0]["ColumnName"]or access theforeach(var item in dr.ItemArray)personally I do not see the need for 2 loops.. and if you return more than 1 row..then your totally screwed...foreach(var item in dr.ItemArrayuse the debugger and you can quickly see how to assign the proper text boxes with the correctitem[0] ...[8]