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++;
}
}
}
}

SUNIL GUTTARank #1,832 · 810 reputationPosted Jan 25, 2014, 9:57 AM EST
Rawan K3 reputationPosted Jan 25, 2014, 10:31 AM EST
Maybe I wasn't clear eenough, if I start with an empty table and no rows, what is a good way to detect that a row has been inserted? This is the exact goal of my StartofSession() code pasted above
SUNIL GUTTARank #1,832 · 810 reputationPosted Jan 25, 2014, 11:02 AM EST
The best practice i suggest is use Stored procedure at DB LEVEL for checking data present r not . Dependingly make SP return 0 r 1 so you can use this at windows forms to know is row present r not.
Well will provide code 2mrw wen i get time .
Regards
SUNIL GUTTARank #1,832 · 810 reputationPosted Jan 25, 2014, 7:43 PM EST
To test it simply initially create empty table and execute there itself in sqserver like
-----------------------------If it helps rate it as best --------------------------------------