previous record problem
-
private void btnPrevious_Click(object sender, System.EventArgs e) { txtAcctID.Clear(); if (Row == 0) { MessageBox.Show("You are at the first patient on the Queue","Beginning Of Queue"); Row = 0; } else { Row = Row --; **txtAcctID.Text= dsPatDia.Tables["PatDia"].Rows[lastrecord]["Acct ID"].ToString(); <-- ERROR!** //FillForm(); } if( Row == 0) { try { oleDbConnection1.Open(); oleDbDataAdapter1.SelectCommand.CommandText = "SELECT Results, Tests, Symptom FROM Dianosis WHERE [Acct ID]= '"+txtAcctID.Text+"'"; oleDbDataAdapter1.SelectCommand.ExecuteNonQuery(); oleDbDataAdapter1.Fill(dsDiag2); Display(dsDiag2); } catch (Exception ConnError) { MessageBox.Show(ConnError.ToString()); } } } private void Display(System.Data.DataSet dsDiag2) { oleDbConnection1.Close(); try { System.Data.DataTable PrevDiag = dsDiag2.Tables[0]; if(PrevDiag.Rows.Count != 0) { txtResults.Text = (string) PrevDiag.Rows[0][3]; txtTests.Text = (string) PrevDiag.Rows[0][4]; txtSymp.Text = (string) PrevDiag.Rows[0][5]; } else { MessageBox.Show("The Patient Record does not exist","Information"); dsDiag2.Clear(); } } catch(Exception Error10) { MessageBox.Show(Error10.ToString()); } }
An unhandled exception of type 'System.NullReferenceException' occurred in CLINICINFORMATIONSYSTEM.exe Additional information: Object reference not set to an instance of an object. how do i rectify this prblem..i want the textbox to display the id of the record before the current one.? CODER -
private void btnPrevious_Click(object sender, System.EventArgs e) { txtAcctID.Clear(); if (Row == 0) { MessageBox.Show("You are at the first patient on the Queue","Beginning Of Queue"); Row = 0; } else { Row = Row --; **txtAcctID.Text= dsPatDia.Tables["PatDia"].Rows[lastrecord]["Acct ID"].ToString(); <-- ERROR!** //FillForm(); } if( Row == 0) { try { oleDbConnection1.Open(); oleDbDataAdapter1.SelectCommand.CommandText = "SELECT Results, Tests, Symptom FROM Dianosis WHERE [Acct ID]= '"+txtAcctID.Text+"'"; oleDbDataAdapter1.SelectCommand.ExecuteNonQuery(); oleDbDataAdapter1.Fill(dsDiag2); Display(dsDiag2); } catch (Exception ConnError) { MessageBox.Show(ConnError.ToString()); } } } private void Display(System.Data.DataSet dsDiag2) { oleDbConnection1.Close(); try { System.Data.DataTable PrevDiag = dsDiag2.Tables[0]; if(PrevDiag.Rows.Count != 0) { txtResults.Text = (string) PrevDiag.Rows[0][3]; txtTests.Text = (string) PrevDiag.Rows[0][4]; txtSymp.Text = (string) PrevDiag.Rows[0][5]; } else { MessageBox.Show("The Patient Record does not exist","Information"); dsDiag2.Clear(); } } catch(Exception Error10) { MessageBox.Show(Error10.ToString()); } }
An unhandled exception of type 'System.NullReferenceException' occurred in CLINICINFORMATIONSYSTEM.exe Additional information: Object reference not set to an instance of an object. how do i rectify this prblem..i want the textbox to display the id of the record before the current one.? CODERThere are at least two things you want to check out: 1. You probably forgot to fill the dataset before you call the methods (or even declared it as new). 2. The table does not exist, the column does not exist, or there are no records in the table. How did you get the lastrecord variable in Rows[lastrecord] anyway? Edbert P. Sydney, Australia.
-
private void btnPrevious_Click(object sender, System.EventArgs e) { txtAcctID.Clear(); if (Row == 0) { MessageBox.Show("You are at the first patient on the Queue","Beginning Of Queue"); Row = 0; } else { Row = Row --; **txtAcctID.Text= dsPatDia.Tables["PatDia"].Rows[lastrecord]["Acct ID"].ToString(); <-- ERROR!** //FillForm(); } if( Row == 0) { try { oleDbConnection1.Open(); oleDbDataAdapter1.SelectCommand.CommandText = "SELECT Results, Tests, Symptom FROM Dianosis WHERE [Acct ID]= '"+txtAcctID.Text+"'"; oleDbDataAdapter1.SelectCommand.ExecuteNonQuery(); oleDbDataAdapter1.Fill(dsDiag2); Display(dsDiag2); } catch (Exception ConnError) { MessageBox.Show(ConnError.ToString()); } } } private void Display(System.Data.DataSet dsDiag2) { oleDbConnection1.Close(); try { System.Data.DataTable PrevDiag = dsDiag2.Tables[0]; if(PrevDiag.Rows.Count != 0) { txtResults.Text = (string) PrevDiag.Rows[0][3]; txtTests.Text = (string) PrevDiag.Rows[0][4]; txtSymp.Text = (string) PrevDiag.Rows[0][5]; } else { MessageBox.Show("The Patient Record does not exist","Information"); dsDiag2.Clear(); } } catch(Exception Error10) { MessageBox.Show(Error10.ToString()); } }
An unhandled exception of type 'System.NullReferenceException' occurred in CLINICINFORMATIONSYSTEM.exe Additional information: Object reference not set to an instance of an object. how do i rectify this prblem..i want the textbox to display the id of the record before the current one.? CODER