Rawan K

Rawan K

  • NA
  • 3
  • 1.2k

C# Windows Forms to SQL connection: error in reading table

Jan 25 2014 7:56 AM
Hey experts! I have a system consisting of a Java Android application that enters information in an SQL server database every certain count of seconds, and I have a C# Windows Form that is connected to the database and reads the entries perfectly fine. My problem is, I need to let the client know when information has STARTED to be entered inside the table, so I tried StartofSessionCheck() that checks whenever the datarow is NO LONGER null (has rows) and informs the client, but I keep getting the error: "there's no row at postition 0"
 
I don't know how to fix this, but maybe my whole methodlogy is wrong. please HELP!
 
NOTE: the marker1 and 2 check makes sure that the session only starts when my columns have ones in them 
 
private void StartOfSessionCheck()
{   
      while (dRow != null ) // when datarow is no longer null, i.e. has a length >0 then proceed
      {
         if (stayinLoop == true)
         {
            dRow = ds.Tables[0].Rows[rowNum]; // reads the first row
            Marker1 = dRow.ItemArray.GetValue(1).ToString();
            Marker2 = dRow.ItemArray.GetValue(2).ToString();
            if (Marker1 == "1" && Marker2 == "1") //make sure my first row has ones in it
            {
               stayinLoop = false; // leave the loop so we can execute the rest of the program
               rowNum++;
              }
         }
      }
}

Answers (4)