- You cannot DELETE some columns and others no, you delete the entire record for which a WHERE clause is verified.
- The sprintf shuld be a matlab command and not a string.
How to delete from MS Access database using GUI interface
2 次查看(过去 30 天)
显示 更早的评论
I prepared the following table with MS Access called 'Table1'. The table is shown below: ID Harzards Location Magnitude Casualties Aids DeathRate 8 1 123 345 321 567 789 9 2 125 675 234 567 123 10 3 123 45 56 23 45 11 4 65 78 34 12 45 12 1 123 345 321 567 789 13 2 125 675 234 567 123 14 3 123 45 56 23 45 15 4 65 78 34 12 45
I used the following code under the GUI interface pushbutton and I received the following error:
CODE: conn = database('grace', ' ',' '); ping(conn); exec(conn, 'DELETE Harzards,Location,Magnitude,Casualties,Aids, DeathRate FROM Table1 {WHERE ID = sprintf(''%f', handles.edit28'')});
ERROR: Error in ==>retrieve2withD>pushbutton4_Callback at 418 exec(conn, 'DELETE Harzards,Location,Magnitude,Casualties,Aids, DeathRate FROM Table1 {WHERE ID = sprintf(''%f', handles.edit28'')});
handles.edit28 holds the value of the ID I intend to delete.
Please, help me out. How do I delete each row in the database table? Also, if I want to import each column in the table, what code do I use? Thank you so much, Oleg, for answering my question yesterday.
0 个评论
回答(1 个)
Oleg Komarov
2011-7-26
exec(conn, ['DELETE FROM Table1 WHERE ID =' sprintf('%f', handles.edit28)]);
1 个评论
hoang
2013-5-2
hi okemini and oleg, would you mind to give me some help, i want to delete a row in table database in MS ACCESS via a ODBC with matlab, i used exec(connA, ['DELETE FROM inputtb WHERE Barcode =' sprintf('%s', idbc)])
idbc holds the value of the row i intend to delete. i tried but it doesn't work.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!