If you need to stop a datareader in the middle, instead of at the end, you have to call cancel on the command object. Calling the Close() method will result in a timeout exception.
using (SqlCommand cmd = new SqlCommand(sql, conn)){
XmlReader reader = cmd.ExecuteXmlReader();
reader.Read();
while (!reader.EOF) {if (this.Cancel){cmd.Cancel();reader.Close():break;}holder = reader.ReadOuterXml(); }
}
Tuesday, December 2, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment