Hello all!
I have a problem with data logging from winCC to SQL server. I am trying to write a single variable type "Real" to SQL server. The problem is that SQL table doesn't show the decimal places. Data type of the variable in SQL database is also Real. "data1" is a HMI tag connected to a DB value of type Real in PLC.
If I send value 5.0, only 5 is written into the database.
VB script code:
Sub VBFunction_2()
Dim objConnection
Dim strConnectionString
Dim strSQL
Dim objCommand
Dim Data1
strConnectionString = "Provider=MSDASQL;DSN=TestODBC;UID=;PWD=;"
Data1=SmartTags("data1")
strSQL = "INSERT INTO TableReal (Number) VALUES ( " & Data1 & " );"
Set objConnection = CreateObject ("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConnection
.CommandText = strSQL
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
End Sub
Has anyone experienced similar issues?
Thank you for helping
I have a problem with data logging from winCC to SQL server. I am trying to write a single variable type "Real" to SQL server. The problem is that SQL table doesn't show the decimal places. Data type of the variable in SQL database is also Real. "data1" is a HMI tag connected to a DB value of type Real in PLC.
If I send value 5.0, only 5 is written into the database.
VB script code:
Sub VBFunction_2()
Dim objConnection
Dim strConnectionString
Dim strSQL
Dim objCommand
Dim Data1
strConnectionString = "Provider=MSDASQL;DSN=TestODBC;UID=;PWD=;"
Data1=SmartTags("data1")
strSQL = "INSERT INTO TableReal (Number) VALUES ( " & Data1 & " );"
Set objConnection = CreateObject ("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConnection
.CommandText = strSQL
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
End Sub
Has anyone experienced similar issues?
Thank you for helping