Getting Error using database/insert (line 177) Unable to write column to database. while exporting data from matlab to SQL Server Management Studio
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aditi Bhalerao
el 17 de Abr. de 2017
Comentada: Aditi Bhalerao
el 20 de Abr. de 2017
Hi I am trying to insert the results of gurobi into Micrsoft Server Management Studio, but I am getting the following error:
Error using database/insert (line 177) Unable to write column to database. I have created a table named results with the following data types:
resultId int
x float
objVal float
cost float
Below is my code:
conn = database.ODBCConnection('MySQL','NCAT\aabhaler','');
conn = database('STEERDB','NCAT\aabhaler','','Vendor','Microsoft SQL Server','Server','A0030110GB6S942','AuthType','Windows','portnumber',1433);
colnames={'resultId', 'x', 'objVal', 'cost'};
data = {1 ,result.x, result.objval ,2.2};
data_table = cell2table(data,'VariableNames',colnames)
tablename = '[dbo].[results]';
datainsert(conn,tablename,colnames,data)
insert(conn,tablename, colnames,data_table);
curs=exec(conn,'select * from [dbo].[results]');
curs=fetch(curs);
disp(curs.Data);
close(curs);
close(conn);
result.x is [1766x1 double] and result.objval is 1.0162e+07.
Can you please help me out?
0 comentarios
Respuesta aceptada
Swathik Kurella Janardhan
el 20 de Abr. de 2017
The issue could be due to the mismatch in the datatypes of result.x and column x in the schema. result.x is an array of doubles where as column x in schema accepts float value.
Más respuestas (0)
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!