Vijeo Citect 7.4 - SQL Error 13

junior_nns

Member
Join Date
Aug 2013
Location
Brazil
Posts
1
Hello!

I'm work with Vijeo Citect 7.4, and I have a connection with SQL Server by ODBC.

Bellow, my string to insert data into SQL Server:

hSQL=SQLConnect("DSN=ODBCNAME;UID=user;PWD=password")
IF hSQL <> -1 THEN
hE1QueryInsert = SQLQueryCreate(hSQL);
SQLSet(hE1QueryInsert, "INSERT IGNORE INTO Table");
SQLAppend(hE1QueryInsert, "(Col1, Col2)");
SQLAppend(hE1QueryInsert, " values (?,?)");
SQLParamsClearAll(hE1QueryInsert);
SQLParamsSetAsInt(hE1QueryInsert, "Col1", iCol1);
SQLParamsSetAsInt(hE1QueryInsert, "Col2", iCol2);

FB_SQL_EXEC = SQLCall(hE1QueryInsert, "");
SQLQueryDispose(hE1QueryInsert);
IF FB_SQL_EXEC <> -1 THEN
ErrLog("Sucess insert data");
ELSE
ErrLog("Error message: " + SQLErrMsg(hE1QueryInsert));
END
SQLDisconnect(hSQL);
ELSE
ErrLog("Connection Error. Error Message: " + SQLErrMsg(hSQL));
END

When I start Vijeo Citect Runtime, the script works fine, but after time, stop to insert data into SQL Server and a message log into syslog.report is generated:"Connection Error. Error Message: SQL Error (13 - Too many connections created) on Handle (-1). Too many existing connections"

Could you help me?!

Best Regards,
Junior
 
seems a little complex to me, this is one I did some years ago it's obvious that the connection is not closing so every time you run the script it creates another one.,

Sub INS ()
On Error GoTo Err
Times = "'" + Format(Now,"yyyy-mm-dd hh:mm:ss") + "'"
BatchIDStr = "'" + Mid(Times,4,2) + Mid(Times,7,2) + Mid(Times,10,2) + Mid(Times,13,2)+ Mid(Times,16,2)+ Mid(Times,19,2) + "'"
CookerStr = "'" + CStr(GetVariableValue("CH3_Revorack3_Current_Total_Phases")) + "'"
CookerStr = "'3'"
RecipeStr = "'" + GetVariableValue(CH3_Revorack3_Current_Recipe) +"'"
'RecipeStr = "'Recipe 1'" 'Temp insert Recipe 1 for testing
Phases = "'" + CStr(GetVariableValue(CH3_Revorack3Current_Total_Phases)) + "'"
'Phases = "'3'"
Conn1.ConnectionString = "dsn=DerbySC;uid='sa';pwd='';"
SQLStr = "INSERT INTO CookerBatch(BatchStarted,BatchID,Cooker,Recipe,No_Phases) Values (" & Times & "," & BatchIDStr & "," & CookerStr & "," & RecipeStr & "," & Phases & ")"
Conn1.Open
Conn1.Execute SQLStr
Conn1.Close
Set Conn1 =Nothing
Debug.Print "Batch Started on Cooker 3 "
Exit Sub
Err:
Debug.Print Error + ": Failed to Write Cooker 3 Batch Details to Database"
Exit Sub
End Sub
 

Similar Topics

I have any trouble about connection from SQL Database server with Vijeo Citect version 7.20, I've made a database in Microsoft SQL Server, and I...
Replies
2
Views
4,624
Hello, I have configure some digital alarm and thats alarm i have to Log in SQL using cicode but when i am trying to this this it cant work...
Replies
0
Views
2,543
My system are taking data from RHT sensors, around 45 points. Now I want to make a function in which, if the data is #BAD or 0 in values for all...
Replies
0
Views
475
I have DI module ICPCon M7024UD connect to my pc using COM3 MODBUS RTU and also RHT sensors are using MODBUS TCPIP.. The problem is, it cannot...
Replies
9
Views
1,667
I need help with vijeo citect 7.4 as I use Modbus TCPIP to get the data, it turns out the address is having error.. For example, when I write...
Replies
2
Views
885
Back
Top Bottom