dimanche 8 novembre 2015

SQLite MATlab with parameters

I'm writing GUI in Matlab and using mksqlite. I have a problem with parameters.

mksqlite([ 'INSERT INTO ' , z , ' VALUES (?)' ], data); where z='table name'

'table name' is choosing from listbox. data to insert are getting from inputdlg. But problem is with (?) parameters because diffrent tables have a diffrent columns number. Anybody know a way to solve this problem to (?) will declare in dynamic manner.

enter code here
a = get(handles.listbox1,'String');
b = get(handles.listbox1,'Value');
tabela=a{b};
disp(tabela);
mksqlite( 'param_wrapping', 1 );
mksqlite( 'result_type', 1 );
[results,colnames] = mksqlite(['SELECT * FROM  ',  tabela])
disp(results);
e=fieldnames(results);
v=size(e);
for r=1:v
  prompt={'Wprowadź '};
dlg_title = 'Wprowadź ';
num_lines = 1;
answer = inputdlg(prompt,dlg_title,num_lines); 
imie=answer{1};
disp(imie);
t=answer{1};
data{r}=t;
disp(data);
z=a{b};
end;



    mksqlite([ 'INSERT INTO ' , z , ' VALUES (?,?,?,?)' ], data);

Aucun commentaire:

Enregistrer un commentaire