properties (Access = public)
UIFigure matlab.ui.Figure
LastNameEditField matlab.ui.control.EditField
LastNameEditFieldLabel matlab.ui.control.Label
FirstNameEditField matlab.ui.control.EditField
FirstNameEditFieldLabel matlab.ui.control.Label
SavetodBButton matlab.ui.control.Button
end
properties (Access = private)
username;
password;
datasource;
data;
tableName;
end
methods (Access = private)
function startupFcn(app)
app.datasource = "MSSQLServerJDBCAuth";
app.username = "";
app.password = "";
app.conn = database(app.datasource,app.username,app.password);
end
function SavetodBButtonPushed(app, event)
app.data = table(app.FirstNameEditField, app.LastNameEditField, 'VariableNames', {'First Name', 'Last Name'});
app.tableName = 'UserInfo';
sqlwrite(app.conn, app.tablename, app.data);
end
end
Best Answer