Fritzfrederix
Chemical
- May 28, 2003
- 63
Hello everybody,
I'm facing at the moment a small problem with VBS. I'm writing data from WinCC towards a SQL Server, that part works but with retrieving this data I got a problem.
I send a date to a Table in an SQL Server
WinCC (datatype) Tex tag 8 bit character set
SQL (datatype) Smalldatetime
For the code see below
strSQL = "INSERT INTO BHI_Measuring_Station (Production_Date) Values ('" & Int(CDate(V15)) &"');"
This part works, now I would like to retrieve this data and I use the following code.
[ladder]V1 = HMIRuntime.Tags("Balenumber_man").Read
Dim objConnection
Dim strConnectionString
Dim strSQL
Dim objCommand
Dim rsData
strConnectionString = "Provider=MSDASQL;DSN=CLaSS_Production;UID=sa;PWD=siemens;database=CLaSS"
strSQL = "Select Production_Date from BHI_Measuring_Station where Balenumber = '" & V1 & "';"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set rsData = CreateObject("ADODB.Recordset")
rsData.Open strSQL,objConnection
If Not rsData.EOF Then
rsData.MoveFirst
V3 = rsData.Fields(0).Value
MsgBox (V3)
Else
MsgBox("Baalnummer bestaat nog niet")
V3 = ""
End If
MsgBox ("OK1") 'HMIRuntime.Tags("Production_Date"))
HMIRuntime.Tags("Production_Date").Write V3
MsgBox (V3) 'HMIRuntime.Tags("Production_Date"))
objConnection.Close
rsData.close
Set objConnection = Nothing
Set rsData = Nothing
MsgBox ("OK3") 'HMIRuntime.Tags("Production_Date"))
End Sub[/ladder]
The Producion_Date is red and U can see it in V3 but it doesn't show anything in HMIRuntime.Tags("Production_Date")
Is there something wrong with
HMIRuntime.Tags("Production_Date").Write V3
Anyone?
I'm facing at the moment a small problem with VBS. I'm writing data from WinCC towards a SQL Server, that part works but with retrieving this data I got a problem.
I send a date to a Table in an SQL Server
WinCC (datatype) Tex tag 8 bit character set
SQL (datatype) Smalldatetime
For the code see below
strSQL = "INSERT INTO BHI_Measuring_Station (Production_Date) Values ('" & Int(CDate(V15)) &"');"
This part works, now I would like to retrieve this data and I use the following code.
[ladder]V1 = HMIRuntime.Tags("Balenumber_man").Read
Dim objConnection
Dim strConnectionString
Dim strSQL
Dim objCommand
Dim rsData
strConnectionString = "Provider=MSDASQL;DSN=CLaSS_Production;UID=sa;PWD=siemens;database=CLaSS"
strSQL = "Select Production_Date from BHI_Measuring_Station where Balenumber = '" & V1 & "';"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set rsData = CreateObject("ADODB.Recordset")
rsData.Open strSQL,objConnection
If Not rsData.EOF Then
rsData.MoveFirst
V3 = rsData.Fields(0).Value
MsgBox (V3)
Else
MsgBox("Baalnummer bestaat nog niet")
V3 = ""
End If
MsgBox ("OK1") 'HMIRuntime.Tags("Production_Date"))
HMIRuntime.Tags("Production_Date").Write V3
MsgBox (V3) 'HMIRuntime.Tags("Production_Date"))
objConnection.Close
rsData.close
Set objConnection = Nothing
Set rsData = Nothing
MsgBox ("OK3") 'HMIRuntime.Tags("Production_Date"))
End Sub[/ladder]
The Producion_Date is red and U can see it in V3 but it doesn't show anything in HMIRuntime.Tags("Production_Date")
Is there something wrong with
HMIRuntime.Tags("Production_Date").Write V3
Anyone?