Re: Direct Data Access - Best Practice?
- From: "William \(Bill\) Vaughn" <billvaRemoveThis@xxxxxxxxxx>
- Date: Tue, 12 Dec 2006 11:31:13 -0800
The only thing I see that I would change is to use "TRUNCATE TABLE
[customer]" instead of DELETE.
This approach is fine. There is no reason to use a disconnected DataTable
for this unless you want the program to run dramatically slower... ;)
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"Saubz" <saubz@xxxxxxxxxxxxxxxxx> wrote in message
news:30192AB6-B6A9-4F80-B3B4-D3419E6C5F91@xxxxxxxxxxxxxxxx
Hello. I currently use a lot of direct data access in ASP - I really
don't
like disconnected for some reason. What I'm wondering is if the method I
use
is acceptable or if there is a better way. This is the basic code I use
every time I want to run a query (of course there are modifications
depending
on the type of query):
Dim connStr As String =
ConfigurationManager.ConnectionStrings("CustomerConnectionString").ConnectionString
Dim conn As New System.Data.SqlClient.SqlConnection(connStr)
Dim cmd As New System.Data.SqlClient.SqlCommand("DELETE * FROM
[customer]",
conn)
Using conn
conn.Open()
cmd.ExecuteNonQuery()
End Using
I use this code a whole bunch, so I'm just wandering if this is alright or
if there is a better way.
Thanks,
Matt
.
- Follow-Ups:
- Re: Direct Data Access - Best Practice?
- From: Saubz
- Re: Direct Data Access - Best Practice?
- Prev by Date: Re: SqlDataReader performance
- Next by Date: Re: Sql 2005 and User Defined Data types
- Previous by thread: Sql 2005 and User Defined Data types
- Next by thread: Re: Direct Data Access - Best Practice?
- Index(es):
Relevant Pages
|