Home > Mobile >  MySQL delete according to specific date and time
MySQL delete according to specific date and time

Time:05-21

How to delete rows from table according to specific date and time in mySQL with vb.net

I have tried the following

DELETE FROM TABLE WHERE TABLE_INPUT = #date_time#

DELETE FROM TABLE WHERE TABLE_INPUT = 'date_time'

DELETE FROM TABLE WHER  TABLE_INPUT = date_time

None of them worked

please help me

CodePudding user response:

It's exactly like deleting based on any other value. You just specify that the parameter is the appropriate type, e.g.

Using connection As New MySqlConnection("connection string here"),
      command As New MySqlCommand("DELETE MyTable WHERE MyColumn = @MyColumn", connection)
    command.Parameters.Add("@MyColumn", MySqlDbType.DateTime).Value = myDateTime
    connection.Open()
    command.ExecuteNonQuery()
End Using

Where and how you get myDateTime is up to you. It might, for instance, come from a DateTimePicker control, e.g.

Dim myDateTime = myDateTimePicker.Value
  • Related