berfin_bar
Üye
- Katılım
- 27 Mar 2009
- Mesajlar
- 26
- Puanları
- 1
Herkese selamlar,
Aşağıdaki kod örneğini winncc 7.0 vb scripte (project modules) altında sub deneme altında yazdım daha sonra actionslardan 1s de bir call ile çağırdım, sql de bir tablo oluşturdum ve sql veri göndermeye çalıştım ama başaramadım bir yerde birşeyleri atlıyorum ama ne ? bulamadım. burda yanlış yapabileceğim yer DSN adı bunu nerden buluyoruz ? atladığım nokta nedir ... yardımlarınız için teşekkür ederim . sorunu çözdüğümde bütün açık kodları doğrusunu burdan paylaşırım.
Create the Access database with the WINCC_DATA table and columns (ID, TagValue) with the ID as the Auto Value.
Set up the ODBC data source with the name "SampleDSN", reference to the above Access database.
Programming.
Example 1
'VBS108
Dim objConnection
Dim strConnectionString
Dim lngValue
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;"
lngValue = HMIRuntime.Tags("Tag1").Read
strSQL = "INSERT INTO WINCC_DATA (TagValue) VALUES (" & lngValue & ");"
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
Aşağıdaki kod örneğini winncc 7.0 vb scripte (project modules) altında sub deneme altında yazdım daha sonra actionslardan 1s de bir call ile çağırdım, sql de bir tablo oluşturdum ve sql veri göndermeye çalıştım ama başaramadım bir yerde birşeyleri atlıyorum ama ne ? bulamadım. burda yanlış yapabileceğim yer DSN adı bunu nerden buluyoruz ? atladığım nokta nedir ... yardımlarınız için teşekkür ederim . sorunu çözdüğümde bütün açık kodları doğrusunu burdan paylaşırım.
Create the Access database with the WINCC_DATA table and columns (ID, TagValue) with the ID as the Auto Value.
Set up the ODBC data source with the name "SampleDSN", reference to the above Access database.
Programming.
Example 1
'VBS108
Dim objConnection
Dim strConnectionString
Dim lngValue
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;"
lngValue = HMIRuntime.Tags("Tag1").Read
strSQL = "INSERT INTO WINCC_DATA (TagValue) VALUES (" & lngValue & ");"
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