|
-
Dec 21st, 2010, 01:16 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Is this the proper syntax to DELETE?
Just a quick verification. Is this the correct syntax to delete a record from a dataset?
Code:
Dim sqlDelete As New SqlClient.SqlCommand("DELETE FROM TIMECARDS WHERE [HOURS] = 0 AND [HOURS2] = 0 AND [HOURS3] = 0 AND [HOURS4] = 0 AND [HOURS5] = 0")
cnxn.Open()
sqlDelete.Connection = cnxn
sqlDelete.ExecuteNonQuery()
sqlDelete.Dispose()
cnxn.Close()
cnxn.Dispose()
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2010, 01:18 PM
#2
Re: Is this the proper syntax to DELETE?
More or less yeah (although there is no dataset in question there.. that is deleting directly from a table in a SQL database). You would want error handling in the event that something throws an exception.
-
Dec 21st, 2010, 01:21 PM
#3
Thread Starter
PowerPoster
Re: Is this the proper syntax to DELETE?
I will put a Try...Catch in there.
I just wanted to make sure that, in NET, I didn't do something stupid like deleting all the records aor the data table itself.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 21st, 2010, 01:26 PM
#4
Re: Is this the proper syntax to DELETE?
No, your WHERE clause will take care of only deleting the records that match those conditions.
-
Dec 21st, 2010, 01:27 PM
#5
Thread Starter
PowerPoster
Re: Is this the proper syntax to DELETE?
Cool. I will mark it resolved then.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|