From: Bhushan Shetty on
hi,
i have connected MATLAB to my access database via ODBC. I can write into data base however cannot update it.
heres the part of the program
curs = exec(conn, 'select BALANCE_AMNT from LICENCE_NOS');
setdbprefs('DataReturnFormat','numeric');
curs = fetch(curs);
BL=curs.Data;
display(BL); %fetched the entire balance coloum from database
c=BL(pos);
display(c) % in variable ' pos ' the position that user wants is stored and var 'c ' has
corresponding value of balance
c=c+str2double(BAL);
display(BAL)
display(c);
colnames={'BALANCE_AMNT'};
exdata={c};
val=pos;
update(conn, 'LICENCE_NOS', colnames,exdata,{'where ID = val' });
%this statement is not being executed if
% instead if I write
update(conn, 'LICENCE_NOS', colnames,exdata,{'where ID = 01 ' });
% then balance corresponding to row 'ID'= 01 is updated

plz suggest me a solution!!!asap!
From: Kirill on
On Apr 5, 5:44 am, "Bhushan Shetty" <bhushi_...(a)yahoo.co.in> wrote:
> hi,
>   i have connected MATLAB to my access database via ODBC. I can write into data base however cannot update it.
> heres the part of the program
> curs = exec(conn, 'select BALANCE_AMNT from LICENCE_NOS');
>     setdbprefs('DataReturnFormat','numeric');
>     curs = fetch(curs);
>     BL=curs.Data;
>     display(BL);  %fetched the entire balance coloum from database
>     c=BL(pos);
>     display(c) % in variable ' pos ' the position that user wants is stored and var 'c ' has
>                      corresponding value of balance
>     c=c+str2double(BAL);
>     display(BAL)
>     display(c);
>     colnames={'BALANCE_AMNT'};
>     exdata={c};
>     val=pos;
>     update(conn, 'LICENCE_NOS', colnames,exdata,{'where ID = val' });
>               %this statement is not being executed if
> % instead if I write    
> update(conn, 'LICENCE_NOS', colnames,exdata,{'where ID = 01 ' });
> % then balance corresponding to row 'ID'= 01 is updated
>
> plz suggest me a solution!!!asap!

try to replace

{'where ID = val' }

with

{sprintf('where ID = %d', val)}

Kirill