|
|
|
Best Syntax to Open a SqlConnection in Asp.Net 2.0 |
|
Posted by
Moderator1
on
1/4/2008 2:48:15 AM |
1294
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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|