skip to main | skip to sidebar

Techie...

Tuesday, December 2, 2008

Quick ADO.net Tip

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(); }
}
Posted by Chandrasekar at 11:25 PM

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blogs I read

Harish Renganathan
Lakshmi
Scottgu
Pandurang Nayak
Somasegar

Blog Archive

  • ►  2009 (3)
    • ►  August (2)
    • ►  July (1)
  • ▼  2008 (23)
    • ▼  December (23)
      • Very useful link for Sql Server - Everyone has to see
      • Important Free tools
      • Create an XSD Schema….without knowing a darn thing...
      • Setting homepage dynamically
      • Microsoft .NET Framework Tools
      • Chart Controls in .net
      • Text To Image Convertor
      • you Shape IT
      • MSDN Architecture Center
      • SharePoint Guidance
      • Quick ADO.net Tip
      • Very Important Link About Memory Leak - Must Read
      • Cool link
      • Copying a website
      • How to Read the HTML of a Web Page Programmatically
      • Patterns & Practices
      • Useful links
      • Free WCF Training
      • Versioning ASP.NET 2.0 WebSite Assembly / Web Depl...
      • Cool links
      • Online GUID Generator
      • RGB in Hex format
      • Download ASP.NET MVC Preview 3
  • ►  2006 (1)
    • ►  November (1)

About Me

Chandrasekar
View my complete profile