Results 1 to 5 of 5

Thread: [RESOLVED] Is this the proper syntax to DELETE?

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [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]

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  3. #3

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Is this the proper syntax to DELETE?

    No, your WHERE clause will take care of only deleting the records that match those conditions.

  5. #5

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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
  •  



Click Here to Expand Forum to Full Width