??? Invoke Error, Dispatch Exception: Source: DAO.Database
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
??? 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 commentaires
Réponses (1)
Walter Roberson
le 11 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur ActiveX dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!