plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WinCC_SQL

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems
View previous topic :: View next topic  
Author Message
talaaaat
Junior
Junior


Joined: 06 Jun 2014
Posts: 5

PostPosted: 26/11/2018 07:45    Post subject: WinCC_SQL Reply with quote

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
View user's profile Send private message
209loc
Junior
Junior


Joined: 20 Jun 2018
Posts: 4

PostPosted: 26/11/2018 19:49    Post subject: Reply with quote

Check the SQL post maybe help you..
It helps me...
Back to top
View user's profile Send private message
tatsoval
Junior
Junior


Joined: 21 Jun 2018
Posts: 3

PostPosted: 26/11/2018 19:54    Post subject: Re: WinCC_SQL Reply with quote

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
View user's profile Send private message
talaaaat
Junior
Junior


Joined: 06 Jun 2014
Posts: 5

PostPosted: 27/11/2018 08:54    Post subject: Reply with quote

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
View user's profile Send private message
talaaaat
Junior
Junior


Joined: 06 Jun 2014
Posts: 5

PostPosted: 27/11/2018 08:56    Post subject: Reply with quote

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
View user's profile Send private message
talaaaat
Junior
Junior


Joined: 06 Jun 2014
Posts: 5

PostPosted: 27/11/2018 09:00    Post subject: Reply with quote

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
View user's profile Send private message
talaaaat
Junior
Junior


Joined: 06 Jun 2014
Posts: 5

PostPosted: 03/12/2018 08:17    Post subject: Reply with quote

Any update .. please
Back to top
View user's profile Send private message
wassy
Junior
Junior


Joined: 16 May 2018
Posts: 1

PostPosted: 03/12/2018 16:34    Post subject: Reply with quote

on this link you get some codes on your problem..
http://plc.myforum.ro/programming-code-and-project-examples-vt8412.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro