×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VBS problem

VBS problem

VBS problem

(OP)
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

[COLOR=red]strSQL = "INSERT INTO BHI_Measuring_Station (Production_Date) Values ('" & Int(CDate(V15)) &"');"[/COLOR]

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"

[COLOR=red]strSQL = "Select  Production_Date from BHI_Measuring_Station where Balenumber = '" & V1 & "';" [/COLOR]  

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"))

[COLOR=red]HMIRuntime.Tags("Production_Date").Write V3[/COLOR]


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?

RE: VBS problem

Hi

I'm sure you've figured this out now but just in case ...

You should explicitly convert V3 (which contains your date) to a string for the WinCC .Write function to accept it.

For example:
HMIRuntime.Tags("Production_Date").Write CStr(V3)

Hope this helps
Salma

RE: VBS problem

(OP)
Salma,

I didn't solve the problem yet, I really tried everything. I even tried Int(Cdate(V3)) and it was so obvious.

Thanks

RE: VBS problem

(OP)
Hello Salma,

I've got one small thing left to ask you if you don't mind?

I'm trying to make a Hardcopy of the screen. I know there is a special function for it but I would like to put it behind a button. I think that's possible but do you know the code in VBS?

Thanks in advance Rudi

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close