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++;
}
}
}
}
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SUNIL GUTTAPosted Jan 26, 2014, 12:43 AM
To test it simply initially create empty table and execute there itself in sqserver like
-----------------------------If it helps rate it as best --------------------------------------
SUNIL GUTTAPosted Jan 25, 2014, 4:02 PM
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
Rawan KPosted Jan 25, 2014, 3:31 PM
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 GUTTAPosted Jan 25, 2014, 2:57 PM