Home Matlab - [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
Reply: 1

Matlab - [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt

JohnAndrews
1#
JohnAndrews Published in 2018-01-11 11:28:17Z

I am running several SQL scripts from Matlab. For the last couple of months, there were no problems with it. However, since this week, I am starting to receive the following error:

Error using database.jdbc.connection/exec (line 53) [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt

I have installed my ODBC driver on Matlab correctly, and I run the SQL queries as follows:

%  connect
conn = database('connectionName','user','password');

% I actually alter between two queries, but put the same here as an example
for i=1:2

   querynew  = "SELECT * FROM tbl";   

   results   = exec(conn, querynew); % the error is triggered here
   results   = fetch(results);
   Data      = results.Data;

end

close(conn)
erg
2#
erg Reply to 2018-01-15 13:38:58Z

Try to close the cursor, using close(results):

for i=1:2

   querynew  = "SELECT * FROM tbl";   

   results   = exec(conn, querynew); % the error is triggered here
   results   = fetch(results);
   Data      = results.Data;
   close(results);

end

https://ch.mathworks.com/help/database/ug/close.html?requestedDomain=true

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302166 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO