How insert data in Database MS access Through User Defined GUI

조회 수: 1 (최근 30일)
shery khan
shery khan 2015년 3월 28일
편집: Geoff Hayes 2015년 3월 29일
can any one tell how to insert data in database through GUI like making some Edit text boxes and Button in GUI and When User click the All Data Is saved in Database please tell me For MS access Database i do this in Under Button
conn = database('MMU2', 'sherykhan', 'shery')
colnames = {'ID','Country'};
edata={user_string1,user_string2}
get(conn, 'AutoCommit')
insert(conn, 'ac_iris', colnames, edata)
close(curs)
close(conn)
and this in two Edit text boxes
user_string2= get(hObject,'String');
user_string1=get(hobject,string);
please tell me the Way i need that when User Will Enter some Data in Edit boxes the Data is Submitted to Database MMU like . i am usin Matlab R2010a Version

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 3월 28일
Shery - use GUIDE to create your GUI with two edit boxes (named edit1 and edit2) and one push button. Then, in the callback to your push button, you can reference the edit boxes using their handles. Something like
function pushbutton1_Callback(hObject, eventdata, handles)
user_string1 = get(handles.edit1,'String');
user_string2 = get(handles.edit2,'String');
then continue with your connection to the MS Access database. See here for details on how to connect with ODBC.
  댓글 수: 8
shery khan
shery khan 2015년 3월 29일
편집: shery khan 2015년 3월 29일
Now Error in oledbcn.m
if true
??? Error using ==> oledbcn at 60
Could not create connection. See troubleshooting
above.
Error in ==> intialpage>pushbutton1_Callback at 221 cn=oledbcn(s);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> intialpage at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)intialpage('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
60 error('Could not create connection. See troubleshooting above.') K>> end
thanks sir your kind help will so Good now tell me Error in insert .m as you previously say that i can add files oledbscntr and other files in my path without editing or change them but now error so please kindly tell me what to do now Thank you So Much sir your Guide lines are so Good for me
Geoff Hayes
Geoff Hayes 2015년 3월 29일
편집: Geoff Hayes 2015년 3월 29일
Unfortunately, shery, the error information that you provided is not enough to determine what the problem is. Have you changed your code, and if so, to what? oledbcn appears to be a function that you have not referenced before. How are you calling this function? What are the inputs?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by