??? Invoke Error, Dispatch Exception: Source: DAO.Database
1 次查看(过去 30 天)
显示 更早的评论
??? 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 个评论
回答(1 个)
Walter Roberson
2011-4-11
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!