- 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!