[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()
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.
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.
Re: Is this the proper syntax to DELETE?
No, your WHERE clause will take care of only deleting the records that match those conditions.
Re: Is this the proper syntax to DELETE?
Cool. I will mark it resolved then.