AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Best Syntax to Open a SqlConnection in Asp.Net 2.0
Posted by Moderator1 on  1/4/2008 2:48:15 AM 10902 Views
Here is the best method to open a SqlConnection in Asp.Net 2.0

using (SqlConnection conn = new SqlConnection("YourConnectionString"))
{
using (SqlCommand cmd = new SqlCommand("YourCommandString", conn))
{
conn.Open();
cmd.ExecuteNonQuery();
}
}

The above syntax opens and closes the connection along with the SqlCommand itself. Every effective in case of any error occurs in database manipulations.

Post New Tips/Tricks View all Tips/Tricks

Featured Resources:
When Good HTML Goes Bad: How You Can Protect Your Web Applications
This webinar highlights how modern attacks target the web browser – and the best practices to safeguard your web applications against these risks.
Introduction to Software Development
This 380 page eBook "Introduction to Software Development" is designed for IT specialists and developers that are starting their way in the free software development universe.
100% Free Subscription until Stock lost.View complete list.
Sponsored by