Undefined function 'fetch' for input arguments of type 'struct'. when reading and writing to an Access Database
Show older comments
Hi all,
This is my first question - please accept my apologies if I format incorrectly.
I call the below code in an infinite loop which runs smoothly for the first ~200 iterations then catches the "Undefined function 'fetch' for input arguments of type 'struct'." error. It is worth noting that in between each iteration I open and close several other tables within the same ODBC connection before reconnecting to this one.
What has me confused is that it runs as it should for the first few hundred iterations. My hunch is that one connection may not close properly but Im not certain.
setdbprefs('DataReturnFormat', 'cellarray');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');
conn = database('ACCESS DB', '', '');
curs = exec(conn, ['SELECT TABLE1.ID_DB'...
' FROM TABLE1 ']);
curs = fetch(curs);
close(curs);
close(conn);
Thanks in advance for any help!
3 Comments
Fox Peterson
on 2 Mar 2014
I thought I would add my silly user experience here, also, because I wasted too much time on the same error for a stupid reason:
Make sure if you used the query builder in the Database toolbox to build your query that you go back into the script and manually type in your password, since it defaults to blank. I was wondering why I couldn't get a connection... I put the password in and of course it was smooth sailing from there.
John Fredy Morales Tellez
on 1 Mar 2017
Thank you very much!
saiharsha gayam
on 20 Mar 2017
where we can get the password and how to type it
Accepted Answer
More Answers (0)
Categories
Find more on Import 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!