Prev: OCR
Next: mex file error
From: Patrick on
Hi

I am using the database toolbox for communication with the MS SQL
database. I execute the same sequence 5-6 times untile suddenly I got
the following message:

Error using ==> database exec
Invalid or closed connection.

The strange thing is that this error occurs once in a time, anyone an
idea what the problem could be or any proposals how I could debug
this error?

Cheers
Patrick
From: Patrick on
I have now more information about the database problem, perhaps
someone has now an idea where the problem could be.
The first lines of the code read as this:

logintimeout(1);

DBConnection = database('Hillo','sa','test');

if length(DBConnection.Message) == 0,
if length(handles.Tabellen.SQLQuery) > 0
if strcmp(SQLQueryModus,'SELECT')
try
Cursor = exec(DBConnection,...
handles.Tabellen.SQLQuery);
catch
disp('DBExecute Error');
end;
....

These are the attitudes of the other objects. The problem seems to be
cause by the cursor object... Anyone an idea?Because the connection
handle and also the SQL query are provided to the function!

DBConnection =

Instance: 'Hillos Produktdaten'
UserName: 'sa'
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: ''
Handle: 0
TimeOut: 1
AutoCommit: 'off'
Type: 'Database Object'

handles.Tabellen.SQLQuery

ans =

SELECT tblArbeitsplatz.APLATZ, tblArbeitsplatz.Bezeichnung,
tblArbeitsplatz.APLATZHierarchie,
tblArbeitsplatz.SerialInternlNumVon,
tblArbeitsplatz.SerialInternlNumBis,
tblArbeitsplatz.SerialExternlNumVon,
tblArbeitsplatz.SerialExternlNumBis FROM tblArbeitsplatz WHERE
(((tblArbeitsplatz.APLATZ)='PD4X__09') AND
((tblArbeitsplatz.aktiv)=1)

Cursor

ans =

Attributes: []
Data: 0
DatabaseObject: []
RowLimit: 0
SQLQuery: []
Message: 'Function requires connection handle and SQL
statement.'
Type: 'Database Cursor Object'
ResultSet: 0
Cursor: 0
Statement: 0
Fetch: 0
From: Patrick on
I have now more information about the database problem, perhaps
someone has now an idea where the problem could be.
The first lines of the code read as this:

logintimeout(1);

DBConnection = database('Hillo','sa','test');

if length(DBConnection.Message) == 0,
if length(handles.Tabellen.SQLQuery) > 0
if strcmp(SQLQueryModus,'SELECT')
try
Cursor = exec(DBConnection,...
handles.Tabellen.SQLQuery);
catch
disp('DBExecute Error');
end;
....

These are the attitudes of the other objects. The problem seems to be
cause by the cursor object... Anyone an idea?Because the connection
handle and also the SQL query are provided to the function!

DBConnection =

Instance: 'Hillos Produktdaten'
UserName: 'sa'
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: ''
Handle: 0
TimeOut: 1
AutoCommit: 'off'
Type: 'Database Object'

handles.Tabellen.SQLQuery

ans =

SELECT tblArbeitsplatz.APLATZ, tblArbeitsplatz.Bezeichnung,
tblArbeitsplatz.APLATZHierarchie,
tblArbeitsplatz.SerialInternlNumVon,
tblArbeitsplatz.SerialInternlNumBis,
tblArbeitsplatz.SerialExternlNumVon,
tblArbeitsplatz.SerialExternlNumBis FROM tblArbeitsplatz WHERE
(((tblArbeitsplatz.APLATZ)='PD4X__09') AND
((tblArbeitsplatz.aktiv)=1)

Cursor

ans =

Attributes: []
Data: 0
DatabaseObject: []
RowLimit: 0
SQLQuery: []
Message: 'Function requires connection handle and SQL
statement.'
Type: 'Database Cursor Object'
ResultSet: 0
Cursor: 0
Statement: 0
Fetch: 0
 | 
Pages: 1
Prev: OCR
Next: mex file error