I am stuck with inserting data into my MS Access Database. I already converted the data into cell array but it still returns me the error indicating that I am inputting the wrong data type.
Show older comments
C =
'SGX 8873 K'
>> iscell(C)
ans =
1
>> datainsert(conn,'VehicleLocation','col2','C')
Error using database/datainsert (line 58)
Input data must be a cell array or numeric matrix.
Been stuck on inserting the data into the database for quite some time now. The input data 'C' is already verified as cell array by the command iscell(C). Anybody got any idea what am I doing wrongly? Thanks.
3 Comments
Walter Roberson
on 20 May 2015
Umakant, examine the below:
>> 'ABC'
ans =
ABC
>> {'ABC'}
ans =
'ABC'
When you see a string with quotes around it and indented, that is indicating a cell array containing the string; if it were a plain string then it would be displayed without the quote marks or indentation.
Tan Jun Hao
on 20 May 2015
Answers (3)
the cyclist
on 20 May 2015
Edited: the cyclist
on 20 May 2015
0 votes
Guessing you want to remove the quotes from around C in the datainsert statement. You are trying to insert the single character 'C', rather than your variable C.
1 Comment
Tan Jun Hao
on 20 May 2015
Edited: Walter Roberson
on 20 May 2015
Walter Roberson
on 20 May 2015
datainsert(conn,'VehicleLocation', {'col2'}, C)
The column names must be cell array of string.
2 Comments
Tan Jun Hao
on 20 May 2015
Walter Roberson
on 20 May 2015
Sorry, I do not have that toolbox, so I cannot check the code to see what is happening.
Thomas Koelen
on 20 May 2015
0 votes
Are you sure you already created a database?
5 Comments
Tan Jun Hao
on 20 May 2015
Thomas Koelen
on 20 May 2015
I didn't see your earlier post but I think this happens when one of the column names specified in a select statement does not exist in the table being queried. so it can't find VehicleLocation, try adding it first!
Tan Jun Hao
on 20 May 2015
Walter Roberson
on 20 May 2015
You do not have a column named 'col2', you have a column named 'LicensePlate'
Tan Jun Hao
on 21 May 2015
Categories
Find more on Export Data Programmatically in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!