You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old February 1st, 2023, 08:52 AM   #1
del1
Member
Slovenia

del1 is offline
 
Join Date: Feb 2023
Location: CE
Posts: 5
WinCC -> SQL real datatype

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
  Reply With Quote
 
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Connecting WinCC Flexible to SQL Server Prince LIVE PLC Questions And Answers 1 March 10th, 2015 03:31 PM
WinCC Flexible 2008 SQL Database Stored Procedure ryang112 LIVE PLC Questions And Answers 1 March 10th, 2015 03:10 PM
WinCC - Report Designer - SQL problem Lesa LIVE PLC Questions And Answers 0 April 4th, 2011 04:03 AM
Strings WinCC -> S7-400 Jeebs LIVE PLC Questions And Answers 2 June 4th, 2010 10:43 AM
WINCC - SQL instructions Fritz_frederix LIVE PLC Questions And Answers 1 May 5th, 2003 09:02 PM


All times are GMT -4. The time now is 05:01 AM.


.