利用matlab向sqlserver的表格中写入数据出现问题
'2022/7/8 10:00:06' '轴承' 2 1 '5~8' 5 5 0'2022/7/8 10:00:06' '统计件1' 2 1 '5~8' 1 1 0
'2022/7/8 10:00:06' '传感器' 3 1 '2~4' 2 2 0
'2022/7/8 10:00:06' '油门杆' 3 1 '2~4' 0 0 1
T2如上所示,是从excel读取为table类型的数据
T2 = readtable('D:\A桌面移动新桌面\维修策略优化\备件.xlsx');
conn = database('SnowSweeper','','');
exec(conn, 'delete from SnowSweeper.dbo.spare_part_program');
insert(conn, 'SnowSweeper.dbo.spare_part_program',{'datetime', 'part_name', 'task_type', 'need_part_num', 'need_part_time', 'stock_num', 'longterm_num', 'purchase_num'}, T2)
close(conn)
然后出现的报错是
错误使用 database.internal.utilities.DatabaseUtils.validateStruct (line 80)
Input structure, dataset or table incorrectly formatted. See help for details
出错 database.odbc.connection/insert (line 140)
data = database.internal.utilities.DatabaseUtils.validateStruct(data);
出错 real_BC_Evaluate7 (line 434)
insert(conn, 'SnowSweeper.dbo.spare_part_program',{'datetime', 'part_name', 'task_type', 'need_part_num', 'need_part_time', 'stock_num',
'longterm_num', 'purchase_num'}, T2) 看错误信息 表格式不对
页:
[1]