| View previous topic :: View next topic |
| Author |
Message |
talaaaat Junior

Joined: 06 Jun 2014 Posts: 5
|
Posted: 26/11/2018 07:45 Post subject: WinCC_SQL |
|
|
In WinCC, I want to save a text into database, I have an I/O field and it's format is string
I created an I/O and assigned for it a text 16 bit tag "internal tag" and made the output format "string"
In the MSQL I created a couloumn of nvchar and it didn't work after that I made it text and it didn't work as well
I am sure that the code is working, because I have 3 another value which is floating |
|
| Back to top |
|
 |
209loc Junior

Joined: 20 Jun 2018 Posts: 4
|
Posted: 26/11/2018 19:49 Post subject: |
|
|
Check the SQL post maybe help you..
It helps me... |
|
| Back to top |
|
 |
tatsoval Junior

Joined: 21 Jun 2018 Posts: 3
|
Posted: 26/11/2018 19:54 Post subject: Re: WinCC_SQL |
|
|
| talaaaat wrote: | In WinCC, I want to save a text into database, I have an I/O field and it's format is string
I created an I/O and assigned for it a text 16 bit tag "internal tag" and made the output compus "string"
In the MSQL I created a couloumn of nvchar and it didn't work after that I made it text and it didn't work as well
I am sure that the code is working, because I have 3 another value which is floating |
What the code do you use? |
|
| Back to top |
|
 |
talaaaat Junior

Joined: 06 Jun 2014 Posts: 5
|
Posted: 27/11/2018 08:54 Post subject: |
|
|
Sub OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)
Dim objConnection
Dim strConnectionString
Dim teto
Dim tetoo
Dim tetooo
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;DSN=Demo;UID=;PWD=;"
teto = HMIRuntime.Tags("total").Read
tetoo = HMIRuntime.Tags("avail").Read
tetooo = HMIRuntime.Tags("down_time").Read
strSQL = "INSERT INTO Table_1 (total,down,avail) VALUES (" & teto & "," & tetoo & "," & tetooo & ");"
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 |
|
| Back to top |
|
 |
talaaaat Junior

Joined: 06 Jun 2014 Posts: 5
|
Posted: 27/11/2018 08:56 Post subject: |
|
|
The data types in the SQL table are float,float,float and text
My problem is in the last column I don't know the problem from the code or the datatype in the SQL table
I tried nvarchar also and it didn't work |
|
| Back to top |
|
 |
talaaaat Junior

Joined: 06 Jun 2014 Posts: 5
|
Posted: 27/11/2018 09:00 Post subject: |
|
|
In WinCC, I created an I/O field and in it's properties, I made the output compus "string"
and I assigned it to internal tag of text tag 16 bit character |
|
| Back to top |
|
 |
talaaaat Junior

Joined: 06 Jun 2014 Posts: 5
|
Posted: 03/12/2018 08:17 Post subject: |
|
|
| Any update .. please |
|
| Back to top |
|
 |
wassy Junior

Joined: 16 May 2018 Posts: 1
|
Posted: 03/12/2018 16:34 Post subject: |
|
|
on this link you get some codes on your problem..
http://plc.myforum.ro/programming-code-and-project-examples-vt8412.html |
|
| Back to top |
|
 |
|