943,981 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 724
  • C# RSS
Oct 24th, 2007
0

how to close a DR and then open it again for use

Expand Post »
Hi all ,
i m using Ms-Access applicaion in c# bt getting error while using a datareader again after closing it.
here is the code.
can any one please help me??????????
if (sCl.Read())
{
if (!(sCl.GetValue(0) is DBNull)) code = sCl.GetInt32(0);
if (!(sCl.GetValue(1) is DBNull)) court = sCl.GetInt32(1);
if (!(sCl.GetValue(3) is DBNull)) party1 = sCl.GetInt32(3);
if (!(sCl.GetValue(4) is DBNull)) party2 = sCl.GetInt32(4);

url = "f:\\manju\\cl\\clsupr\\" + code + ".htm";
webProcFile.Navigate(url);
webProcFile.Show();
get.Connection = src;
get.CommandText = "select Code,Court from caselaw where ( Court > " + code1 + " AND Court < 21 AND ((Party1=" + party1 + " AND Party2=" + party2 + ") OR (Party1=" + party2 + " AND Party2=" + party1 + ")))";
if (stat.HasRows) stat.Close();
stat = get.ExecuteReader();

}
else
sCl.Close();
}
it is showing error in stat = get.ExecuteReader();
please help e in solving this problem.
Thanx in advance.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
manjusaharan is offline Offline
35 posts
since Sep 2007
Oct 24th, 2007
0

Re: how to close a DR and then open it again for use

Once the DataReader is closed, it is a null object. You need to reinitialize it as a new DataReader.
stat = new SqlDataReader();
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: how to use hexadecimal value to obtain the character value in c#
Next Thread in C# Forum Timeline: Reading .dat file data into an array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC