Thursday, 12 September 2013

Resultset not giving values (not entering in while loop)

Resultset not giving values (not entering in while loop)

I have following code in android:
protected void onPostExecute(ResultSet rsData)
{
try
{
int size=0;
while(rsData.next())
{
size++;
}
mlst = new String[size];
int i=0;
while(rsData.next())
{
String mid = rsData.getString(rsData.findColumn("mid"));
String uid = rsData.getString(rsData.findColumn("uid"));
String messages =
rsData.getString(rsData.findColumn("message"));
String
read=rsData.getString(rsData.findColumn("rstamp"));
mdb.addMessage(new Contact(mid, uid, messages, read));
mlst[i]=mid;
i++;
}
con.UpdateMessage(mlst);
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
In this i kept debugger on each line.
I found that in first while loop value of size becomes 7.
Means there are 7 rows in rsData ResultSet.
But as soon as it comes on second while loop, it suddenly does not enters
in while loop and control directly goes to line : con.UpdateMessage(mlst);
I am not able to understand why its happening so?
If resultset has 7 rows in it, then it should enter in it 7 times, but its
not entering a single time.
Please help me.

No comments:

Post a Comment