Forum search

Join Date
Apr 2003
Location
Belgium
Posts
434
Hello,

I'm working on a project with a WinCC 6.0 application which communicates on one side with a S7-300 and on the other side with a SQL Sever 2000.
The WinCC PLC communication works perfectly but I have some problems with the communication towards the SQL Server.
I'm trying to send some tekst (example G1 or H2 ect) from WinCC towards the SQL Server, I use in WinCC the datatype String (CStr) and I use the datatype Char 16 in the SQL Server.
I'm using Visual Basic Scripting. Each time I would like to send this data I recieve this error message of my VBS debugger

[Microsoft][ODBC SQL Server Driver][SQL Server]The name 'G3' is not permitted in this context. Only constants,expressions, or variables allowed here. Column names are not premitted

This is the VBS I wrote

Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)

Dim objConnection

Dim strConnectionString

Dim lngValue

Dim strSQL

Dim objCommand


strConnectionString = "Provider=MSDASQL;DSN=CLaSS_Production;UID=sa;PWD=siemens;database=CLaSS"

lngValue = HMIRuntime.Tags("Linenumber").Read

strSQL = "INSERT IGNORE INTO BHI_baalhoek (linenumber) Values ( " & CStr(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

MsgBox ("data Is Verzonden")

End Sub


Anyone who knows what I'm doing wrong
 
I'm trying to send some tekst (example G1 or H2 ect) from WinCC towards the SQL Server, I use in WinCC the datatype String (CStr) and I use the datatype Char 16 in the SQL Server.
Are you sure ? Is that ´G3´ linenumber ?
 
Hi Seppoalanen,

I'll try to clearify. We are a company who produces fibers out of Celulose Acetate. We have 11 machines (called Metiers) with each 3 positions. So we have in total 33 lines. All of those lines go into a dryers called the A-dryer, B-dryer, C-dryer, G-dryer and H-dryer.
On each dryer we've got 7 positions numbered 1 to 7. So, the operators need to select on a pull-down menu (Combobox) in my WinCC application with which line they are working with (A1, A2, A3 ... H7).

What I would like to do is transfer these selected data (A1, A2, .. H7) towards an SQL-Server and put it in a column called Linenumber. Every time one pushes the button 'send' the column has to be filled out with the selected tekst (A1, A2, ... or H7).

I'm not using the SQL-Server on the PC where WinCC is installed on but I use a SQL-Server on an other Server. The configuration is WinCC => ODBC-driver => SQL-Server. WinCC uses Visual Basic Scripting and the only Datatype is Variant. For more info about Variant in VBS follow this Link.
Hopes this helpes
 
I think column name in SQL-Server is case-sensitive 'linenumber', is it correct ?

If I give in a numeric value instead of a Alfanumeric value then it works. So it isn't a case sensitive problem.

Thanks anyway

Next week I going to a WinCC course and as soon as I know the answer to this question I'll let you know.
 
Hi seppoalanen,

I've promised to come up with the solution, well here it is.

strSQL = "INSERT IGNORE INTO BHI_baalhoek (linenumber) Values ( '" & CStr(lngValue) & "' );"

I didn't received the answer from Siemens but from a guy in the
www.TEK-TIPS.com forum. Nice forum by the way. Has one forum especialy for VBS.

Rudi
 

Similar Topics

I was wanting to search through the forum for a topic that I know has been discussed in the past. everytime I try to search it sends me to the...
Replies
21
Views
4,664
Hi Folks, Check out the video below for some exciting new features and functionality. Enjoy,
Replies
14
Views
51,486
  • Locked
  • Sticky
Hi folks, If you're having any login issues kindly send an email to [email protected] or use the 'contact us' link on the bottom of every page to get...
Replies
0
Views
733
Hi Folks, After many, many hours of setup/testing/tuning/etc I'm happy to announce our brand new shiny PLC forum is coming out of beta and...
Replies
30
Views
2,036
Hi All, Firstly… Merry Christmas to all of you! Secondly, as some of you may have noticed I made some modifications to our backend to address...
Replies
29
Views
6,988
Back
Top Bottom