Got error export data from workspace into database
1 次查看(过去 30 天)
显示 更早的评论
How can i insert data from workspace into database?this is my code.
tableP=[0.02 0.01;0.02 0.01;0.02 0.01;0.02 0.01]; %my data
h = actxserver('DAO.DBEngine.36');
database = 'C:\Users\tV CaLeR\Documents\MATLAB\Maisarah BITD\cm1\data.mdb';
db = h.OpenDatabase(database);
tbl_names = {'data1'};
sql = ['INSERT * INTO ' char(tbl_names(1))];
rs = db.OpenRecordset(sql);
[row,col] = size(rs.GetRows(1));
rs.MoveLast;
ile_wierszy = rs.RecordCount;
rs.MoveFirst;
first=tableP(:,1)
secnd=tableP(:,2)
insert(db,'data1',first,secnd)
rs.Close;
db.Close;
i have this following error,
??? Invoke Error, Dispatch Exception:
Source: DAO.Database
Description: Syntax error in INSERT INTO statement.
Help File: jeterr40.chm
Help Context ID: 4c577e
Error in ==> Untitled at 9
rs = db.OpenRecordset(sql);
please help me..
0 个评论
回答(2 个)
Oleg Komarov
2011-4-10
The correct expression for an INSERT is:
INSERT table_name
VALUES (value1, value2, ...)
or
INSERT table_name
SELECT field1, field2, ... FROM other_table
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!