??? Invoke Error, Dispatch Exception: Source: DAO.Database
4 views (last 30 days)
Show older comments
??? Invoke Error, Dispatch Exception: Source: DAO.Database Description: Syntax error in INSERT INTO statement. Help File: jeterr40.chm Help Context ID: 4c577e Error in ==> getrecords at 11 invoke(db,'Execute',x);
cn=actxserver('Access.application');
db=invoke(cn.DBEngine,'OpenDatabase', 'C:\test.mdb');
rs=invoke(db,'OpenRecordset','Table1');
fieldlist=get(rs,'Fields');
ncols=get(fieldlist,'Count');
for c=1:double(ncols)
fields{c}=get(fieldlist,'Item',c-1);
resultset.columnnames{c}=get(fields{c},'Name');
end;
x='INSERT INTO Table1 (percent,value) VALUES (33,"abcdefg")';
invoke(db,'Execute',x);
invoke(rs,'Close');
invoke(db,'Close');
delete(cn);
what i'm doing wrong? can someone expert repair my code correctly? i'm lack of knowledge about DB..here my code Thanks Amir
0 Comments
Answers (1)
Walter Roberson
on 11 Apr 2011
x='INSERT INTO Table1 (percent,value) VALUES (33,''abcdefg'')';
That is, the syntax for an SQL string is quoting with apostrophes, not with double-quotes. In order to indicate that you want an apostrophe in a MATLAB string, use two apostrophes in a row.
0 Comments
See Also
Categories
Find more on ActiveX in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!