Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. previous record problem

previous record problem

Scheduled Pinned Locked Moved C#
helpquestiondata-structures
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ASGill
    wrote on last edited by
    #1

    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

    E D 2 Replies Last reply
    0
    • A ASGill

      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

      E Offline
      E Offline
      Edbert P
      wrote on last edited by
      #2

      There 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.

      1 Reply Last reply
      0
      • A ASGill

        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

        D Offline
        D Offline
        dishanf
        wrote on last edited by
        #3

        Hi , Find the exact line it occers. it says your object(may be oleDbConnection1 ) is still null, but your going to call its method. D!shan

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups