Help - Search - Members - Calendar
Full Version: Wonderware writing to SQL DB
Forums.MrPLC.com > PLCs and Supporting Devices > General Topics - The Lounge > HMI & SCADA
Conor
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
crashcup
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
Paul OConnell
QUOTE(Conor @ Mar 6 2009, 10: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


Conor,

If you have InTouch installed you could use the SQL Access Manager guide that comes as part of the InTouch installation. You will need to go to Start---->All Programs---->Wonderware---->Books. There are also demo applications available which demo most of what you want to do.

If you need any further help don't hesitate to email me.

Paul O'Connell
Technical Resource Manager
Wonderware UK & Ireland
Conor

[/quote]

Conor,

If you have InTouch installed you could use the SQL Access Manager guide that comes as part of the InTouch installation. You will need to go to Start---->All Programs---->Wonderware---->Books. There are also demo applications available which demo most of what you want to do.

If you need any further help don't hesitate to email me.

Paul O'Connell
Technical Resource Manager
Wonderware UK & Ireland
[/quote]

Hi Paul,

Thanks for that. I got it working and am now writing to the DB.

I now want to query the DB and write the result to a web page via php. I have set-up WAMP on my PC and am trying to get connection to MsSQL.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.