That's some ugly code dude.
Make sure you not confusing .Read() with .NextResult().
You can download a complete DataReader example at:
5/24/2006
Custom Objects/Collections and Tiered Development
http://sholliday.spaces.live.com/blog/
And try to create an object which has placeholders for you values.
Then return that object.
Then do your biz rules/ string making.
public Class MyReturnObject
{
public string Nout
public string Pout
public MyCollection Diseases
}
somethikng like that.
your code is a hodgepodge mess of business rules and data access logic.
"Shum" <sh******@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
>
Hi all.. i have another problem! The Read() method is supposed to
read through all the rows one by one untill no row is left to be
read... but not in my case.. after mySqlDataReader.Read() returns
true first time and gives the value in nout. etc.. it works fine, i
mean it executes fine the first time but when again it comes to the
while statement , " mySqlDataReader.Read()" is false whereas its
supposed to be true .. i checked if values are being read, by the
following code:
while(mySqlDataReader.Read())
{
string
nout=System.Convert.ToString(mySqlDataReader["Outbreak"]);
MessageBox.Show(nout);
}
but when writen as below, its making me crazy... i can do it with the
dataset but wanted to use datareader. plz help if u know how to
overcome it
while(mySqlDataReader.Read())
{
string nout=System.Convert.ToString(mySqlDataReader["Outbreak"]);
MessageBox.Show(nout);
for(int ii=0;ii<=rowcount;ii++) //iterate through the dataset or rows
{
string pout=System.Convert.ToString(ds.Tables["Patients"].Rows[ii]
["OutbreakDisease"]);
if(pout==null)
{
break;
}
else if (pout==nout)
{
if (diseases[0]==null)
{
diseases[count]=pout;
count=count+1;
}
else
{
for(int bi=0;bi<count;bi++)
{
if (diseases[bi]==pout)
{
break;
}
else
{
diseases[count]=pout;
count=count+1;
}
}
}
else if (pout!=nout)
{
continue;
}
}
}
msg=diseases[0]+diseases[1]+" are on outbreak";
MessageBox.Show(msg,"ALERT",MessageBoxButtons.OK,M essageBoxIcon.Information)
;
>
mySqlDataReader.Close();
conn1.Close();
}
catch (Exception ex)
{