delete selected cell from data base SQL

8 ビュー (過去 30 日間)
Cristian Martin
Cristian Martin 2022 年 6 月 11 日
回答済み: Divyam 2025 年 6 月 13 日
Hi, I have a uitable GUI loaded from an SQL DB and I want to select a row from table and delete also from SQL DB, could you give me a direction ?
D=get(handles.uitable4,'Data');
Index=get(handles.uitable4,'UserData');
D(Index.Indices(:,1), :) = [];
set(handles.uitable4,'Data',D);% here a delete the row only from uitable
conn = database('data_base', '', '');
curs = exec(conn, 'SELECT * FROM prices.prices order by Crt desc');
curs = fetch(curs);
close(curs);
I use R2015a.
Thanks
  1 件のコメント
Cristian Martin
Cristian Martin 2022 年 6 月 11 日
function uitable1_CellSelectionCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) currently selecteds
% handles structure with handles and user data (see GUIDATA)
handles = guidata(uitable1);
data = get(uitable1, 'Data');
index = Event.Indices;
set(handles.text15, sprintf('%g', data(index(1), index(2))));
I'm trying to get value from cell selected but somewere i'm wrong, where?

サインインしてコメントする。

回答 (1 件)

Divyam
Divyam 2025 年 6 月 13 日
Here are a few general troubleshooting steps for the function call to "uitable1_CellSelectionCallback":
  • Check the type of data stored in uitable. If the data stored is numerical then your call to the "set" function is correct, else you would need to use array indexing for cell arrays in the function call.
  • Use "eventdata" instead of "Event" in the function to fetch the indexes as "Event" is not defined in the scope of the "uitable1_CellSelection" function call. Also check the if the "eventdata" is empty or contains some values.
As good practice, it is useful for community members to have access to the relevant parts of the code to provide further help with debugging. Feel free to comment if the above steps are not helpful in resolving your issue.
For more information regarding cell arrays, refer to the following documentation: https://www.mathworks.com/help/matlab/ref/cell.html

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by