-2
I have this code that supposedly erases the date I put in the method from Database. But it’s not deleting from Database and I don’t understand why. Here is the information :
public void deleteRowWhitDate(String date){
String query = "DELETE FROM " + TABLE_NAME+ " WHERE "+ COL_4 + " = " + date ;
database.execSQL(query);
}
I’m sure Database contains the date I date.
public static final String TABLE_NAME = "Exames_table";
public static final String COL_4 = "DIA";
Making the
Log.d("debug",query);
I obtained :
DELETE FROM Exames_table WHERE DIA = 30-07-2017
Debug the operation and get the final string of the query variable and try to run directly in the database.
– karanalpe
Makes
Log.d("debug", query);
before she is executed indatabase.execSQL(query);
and say what you have– Isac
What type you used when you created the "DIA" column in the table (Text, INTEGER, etc.) and says an example of value that you pass in the String date.
– Márcio Oliveira
Example : 30-07-2017 , I used Text type
– Pedro Gouveia
@Isac gave this DELETE FROM Exames_table WHERE DIA = 30-07-2017
– Pedro Gouveia
@Pedrogouveia believe that the sql syntax is wrong! Try to run this sql in some DBMS. Possibly the date is not recorded this way (30-07-2017) in the bank. And if it is necessary to put the ' character to work. Example: DELETE FROM Exames_table WHERE DIA = '30-07-2017'
– karanalpe
@Karanpereira Yes put ' helped already worked thanks !
– Pedro Gouveia