??? Invoke Error, Dispatch Exception: Source: DAO.Database

4 visualizaciones (últimos 30 días)
Amir Hamzah UTeM
Amir Hamzah UTeM el 11 de Abr. de 2011
??? 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

Respuestas (1)

Walter Roberson
Walter Roberson el 11 de Abr. de 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.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by