LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Database connection fails after many database and OPC connection/discon cycles

I'm using CVI 6.00, and the SQL toolkit for CVI, and all database I/O worked great, until I started using OPC (datasockets to get to an OPC server).

The following code just connects to the database, disconnects, performs the OPC connection code, delays 100 msec, disconnects from the OPC server. Waiting until the OPC connection is actually made has no effect.

The code is pretty simple, but fails to connect to the database after about 1,043 cycles. I have tried this on a clean install of Win2K, but it fails after 1057 cycles.
0 Kudos
Message 1 of 5
(3,308 Views)
Hello

I doubt datasocket would have anything to do with this. I noticed in your code that you keep opening and closing the datasocket connections without actually checking to see if the connection was active. Try something like this


if(DS_Open ("dstp:\\\\MSDAQDOTNET\\SampleNum", DSConst_ReadAutoUpdate, NULL,
NULL, &dsReadHandle)<0)
goto there;
//Delay(5);
DS_GetStatus (dsReadHandle, &status);
if(status==DSConst_ConnectionError)
goto there;

while(isit=0)
DS_IsConnected (dsReadHandle, &isit);

Delay(0.5);
DS_DiscardObjHandle (dsReadHandle);
goto here;
there:



And also add some delays before opening the database connection and then closing it.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 5
(3,308 Views)
OK, I tried this, which is close to what you have:

int main (int argc, char *argv[])
{
here:
i++;
hdbc = DBConnect ("DSN=genesis");
resCode = DBDisconnect (hdbc);
if ( (resCode != DB_SUCCESS)|(hdbc<=0) )
{
sprintf(msgbuff,"\\TRCIM system disconnection Error.\r\nProgram aborted.....\\TN\n");
goto there;
}

if (DS_Open ("opc://nts180/CIMPLICITY.HMI.OPCServer/\\\\UTILITIES\\!!OPC_POINT.VALUE",
DSConst_Read, NULL, NULL, &dsReadHandle)<0)
goto there;
DS_GetStatus (dsReadHandle, &status);
while (status==DSConst_Connecting)
{
Delay(0.01);
DS_GetStatus (dsReadHandle, &status);
}
if( (status==DSConst_Unconnected)|(status==DSConst_ConnectionError) )
goto there;
Delay(0.25);
DS_DiscardObjHandle (dsRe
adHandle);
goto here;
there:
i++;
i--;
}


It again stops after 1043 cycles.

I coded this in LabVIEW 6.1, and after 5000+ cycles, no issues (see attched file)
0 Kudos
Message 3 of 5
(3,308 Views)
I am having the same problem in
CVI: Version 7.0
OS: Windows2000

DS_Open() fails with fatal run-time error after 1056 cycles and I got the dialog box with
Title: ComponentWorks
Message: Error Creating default control

Any idea why this is happening?
0 Kudos
Message 4 of 5
(3,308 Views)
I hoped I was the only one with this problem, but apparently not.

Does from NI have an idea??????
0 Kudos
Message 5 of 5
(3,308 Views)