4/2/2013 3:42 AM | |
Posts: 140 Rating: (0) |
Dear Whiteford, Thanks for your suggestion. I tried again by inserting application window in the runtime but couldn't modify the database value from the runtime. I tried keying value in the I/O field but nothing chancged on the database. Please refer to the attached pictures for details. I am running the script under Global Script/VBS/Actions. Please let me know if I am doing anything wrong. Thanks
AttachmentDatabaseAccess.pdf (767 Downloads) |
Last edited by: Khyzer at: 4/2/2013 4:00 AM |
|
4/2/2013 4:39 AM | |
Posts: 140 Rating: (0) |
Hi Whiteford, I am recieving following errors. When I run action1 which is your provided code, I recieve error as attached. When I run action2 which was the very first code I used (available on Siemens online help) I recieve a different error. Please suggest Thanks Khyzer
AttachmentDatabaseAccess_error.pdf (455 Downloads) |
4/2/2013 5:02 AM | |
Posts: 140 Rating: (0) |
Dear Whiteford, For the action2, siemens help code, I modified the select statment and now I recieve the attached error. Pleas esuggest. Thanks
|
4/11/2013 3:03 PM | |
Posts: 1776 Rating: (95)
|
HI, have you also seen this FAQ http://support.automation.siemens.com/WW/view/en/16514261 |
4/11/2013 3:19 PM | |
Posts: 140 Rating: (0) |
Dear April, Thanks for your reply. Yes I have seen this FAQ and I have implemented this similiar solution for my issue as explained earlier in this post. But now I want to make a slight modification to the code to read the value of I/O field and search the value corresponding to that, like a look up table. Please read carefully. Thanks Khyzer
|
4/12/2013 4:33 AM | |||||||||
Posts: 140 Rating: (0) |
Dear Experts, I have got the above task working. Now I need to look into the case where user key in a value which is not in the table. Like user key in 26.5 so it should output interpolated value between 30 and 35. Any suggestions? Thanks Khyzer
|
||||||||
4/18/2013 4:05 AM | |
Posts: 140 Rating: (0) |
Dear Experts, I have tested some SQL Queries on the above database using a 3rd part Software (MDB Viewer) and they work fine. However I tried to implment that in WinCC but unable to achieve any success. I have three following quries: first query called interpolation_left: SELECT TOP 1 1 AS id, [VAL] AS val_left FROM TAGS WHERE [TAGNAME] < '"&InputValue&"' ORDER BY [TAGNAME] DESC;
|
5/6/2013 12:16 PM | |||||||||
Posts: 140 Rating: (0) |
Dear Experts, I want to run multiple queries within the code below which works fine for running a single query to access data from an access database. Can anyone help me to modify the code to run more than one queries and save them in seperate variables? Code to search value of column ‘VAL’ by inputting value for column ‘TAGNAME”
'VBS108a Dim objConnection Dim objCommand Dim objRecordSet Dim strConnectionString Dim strSQL Dim lnputValue Dim lngValue Dim lngCount strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;" lnputValue = HMIRuntime.Tags("TagB").Read strSQL = "Select VAL from TAGS WHERE TAGNAME='"&lnputValue&"'" Set objConnection = CreateObject ("ADODB.Connection") objConnection.ConnectionString = strConnectionString objConnection.Open Set objRecordSet = CreateObject ("ADODB.Recordset") Set objCommand = CreateObject ("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = strSQL Set objRecordSet = objCommand.Execute lngCount = objRecordset.Fields.Count If (lngCount> 0) Then objRecordset.movefirst 'lngValue objRecordSet.Fields = (0). Value lngValue = objRecordset.Fields(0).Value 'lngValue = lnputValue HMIRuntime.Tags ("TagC"). Write lngValue Else HMIRuntime.Trace "Selection returned no fields" & vbNewLine End If Set objCommand = Nothing objConnection.Close Set objRecordSet = Nothing Set objConnection = Nothing |
||||||||
5/7/2013 12:08 PM | |
Posts: 1530 Rating: (59)
|
Hello Khyzer, |
5/7/2013 3:04 PM | |
Posts: 140 Rating: (0) |
Dear Bizur, Thanks for the reply> Defining new strSQL2 is not a problem, I am facing problem to sequentially fetch it from the database. Becasue objconnection fetches one strSQL value upon running. I want to run multiple queries and fetch values within one loop. Thanks
|
5/8/2013 5:55 PM | |
Joined: 10/18/2012 Last visit: 12/15/2023 Posts: 225 Rating: (23) |
Hello Khyzer, I'm not sure what is the problem about fetching data sequentially from the database. You can run multiple queries sequentially and use the same database connection for each query. You only need to call the function objCommand.Execute with different CommandText values:
regards, xnor |
12/3/2013 8:54 AM | |
Joined: 4/24/2009 Last visit: 2/19/2024 Posts: 2683 Rating: (135) |
New question was splitted to write data from WinCC to SQL Best regards O_Moderator |
Follow us on