QUOTE(Conor @ Mar 6 2009, 05:33 AM) [snapback]79633[/snapback]
Hi,
I am running Wonderware ver 10, sp2. I am trying to write into a DB via SQL commands from InTouch. I was wondering if anyone has any examples of the script that I need to use.
I know that I need to Connect to DB run command and then disconnect from DB.
Basically I want to add data from flow meters to the DB, but as these will be continually updating, I am not sure of the correct way to script this.
Any help would be great.
Thanks, Conor
A. Install the SQL Database (DB). You'll need to know all about the tables.
B. Set up a System DNS connection to the DB in Control Panel, Administrative Tools, Data Sources(ODBC)
A. Then set up the WW SQL tags you want to read data into from the DB.
C. Then set up your Bind List - (This maps your WW SQL tags to the fields in the DB. Match data types exactly.)
Then in your script, set up a connection to your DB.
(Code Snippet)
Connection_String="DSN=dsn_myApp;APP=Microsoft Windows Operating System;WSID=(local);DATABASE=myDatabase;Trusted_Connection=Yes";
SQLResultCode=SQLConnect(SQL_ConnectionID,SQLConnectionString);
IF SQLResultCode <> Then {check if connection was made}
ErrorMessage = SQLErrorMessage(SQLResultCode);
Endif;
(To insert a record into the database)
(Code Snippet)
SQLResultCode = SQLInsert (SQL_Connection_ID, "Table NAme", "Bindlist Name");
To Close the DB connection
(Code Snippet)
SQLEnd(SQL_Connection_ID);
All the SQL instructions (with help) are available in WW. Also check the WW support website for examples and technotes. www.wonderware.com