Exiting a using block calls .Dispose() on the object in question (cn
in your example) which for a SqlConnection will close the connection and any open resources.
More Related Contents:
- Does this code prevent SQL injection?
- Update primary key value using entity framework
- Using “GO” within a transaction
- How do I write LINQ’s .Skip(1000).Take(100) in pure SQL?
- How can you name the Dataset’s Tables you return in a stored proc?
- Using a variable for table name in ‘From’ clause in SQL Server 2008
- Syntax not valid on word ‘ON’ in SQL join statement [closed]
- How do you effectively model inheritance in a database?
- How does SQLParameter prevent SQL Injection?
- store image in database or in a system file? [closed]
- Parse Delimited CSV in .NET
- Fastest way to perform nested bulk inserts with scope_identity() usage?
- Is the Microsoft.VisualBasic namespace “true .NET” code?
- Bulk Insert to Oracle using .NET
- SqlDateTime.MinValue != DateTime.MinValue, why?
- Code to validate SQL Scripts
- SqlConnection.Close() inside using statement
- Option Strict On and .NET for VB6 programmers
- Cause this VB6-like smell, which VB.NET allows, to error instead: WinFormType.InstanceProp=Value [DISABLE My.Forms]
- How to print datagridview table with its header in vb.net?
- How to draw a signature and save it to disc as a Bitmap?
- Form’s TransparencyKey leaves ghastly colored edging [closed]
- Redirect Trace output to Console
- How to make a Windows Forms .NET application display as tray icon?
- LinqToSql declare and instantiate DataContext best practice?
- .NET, the SqlConnection object, and multi-threading
- Implementing transactions over multiple databases
- Use SQL Server time datatype in C#.NET application?
- Is there a way to define an implicit conversion operator in VB.NET?
- Is SqlConnection.Close() need inside a Using statement?