Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

.NET API to query ClearSCADA View

EcoStruxure Geo SCADA Expert Forum

Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Remote Operations
  • EcoStruxure Geo SCADA Expert Forum
  • .NET API to query ClearSCADA View
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
sbeadle
Kirk sbeadle Kirk
307
AndrewScott
Admiral AndrewScott
95
BevanWeiss
Spock BevanWeiss
89
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
36
View All
Related Products
product field
Schneider Electric
EcoStruxure™ Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to EcoStruxure Geo SCADA Expert Forum
Solved
Kan
Ensign Kan
Ensign

Posted: ‎2020-06-28 10:27 PM . Last Modified: ‎2023-05-03 12:13 AM

0 Likes
4
2985
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2020-06-28 10:27 PM . Last Modified: ‎2023-05-03 12:13 AM

.NET API to query ClearSCADA View

Hello! I need to replicate some logic in ClearSCADA code in .NET. The scada code selects values from a View and does some processing.


Does anyone know what API calls can query the View and get its data? Thanks a lot.

Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2020-06-29 02:51 AM

0 Likes
2
2979
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2020-06-29 02:51 AM

What do you mean by a View - a SQL query?

 

An SQL query can be made on the .Net API using the Advanced connection type.

 

// Non-working code as an example:
                var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);

                AdvConnection = node.Connect("mytest", false); // New type argument
                using (var spassword = new System.Security.SecureString())
                {
                    foreach (var c in password)
                    {
                        spassword.AppendChar(c);
                    }

                    AdvConnection.LogOn(user, spassword);
                }
// Fix indenting!
			Int32 result = 0;
                        String sql = "select id from cgroup"
			// Find the database reference of the thing
			ClearScada.Client.Advanced.IQuery serverQuery = AdvConnection.PrepareQuery(sql, new ClearScada.Client.Advanced.QueryParseParameters());
			ClearScada.Client.Advanced.QueryResult queryResult = serverQuery.ExecuteSync(new ClearScada.Client.Advanced.QueryExecuteParameters());

			if (queryResult.Status == ClearScada.Client.Advanced.QueryStatus.Succeeded || queryResult.Status == ClearScada.Client.Advanced.QueryStatus.NoDataFound)
			{
				if (queryResult.Rows.Count > 0)
				{
					// Found
					IEnumerator<ClearScada.Client.Advanced.QueryRow> e = queryResult.Rows.GetEnumerator();
					while (e.MoveNext())
					{
						result = (Int32)e.Current.Data[0];
					}
				}
			}
			serverQuery.Dispose();

See Answer In Context

  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 4
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2020-06-29 02:51 AM

0 Likes
2
2980
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2020-06-29 02:51 AM

What do you mean by a View - a SQL query?

 

An SQL query can be made on the .Net API using the Advanced connection type.

 

// Non-working code as an example:
                var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);

                AdvConnection = node.Connect("mytest", false); // New type argument
                using (var spassword = new System.Security.SecureString())
                {
                    foreach (var c in password)
                    {
                        spassword.AppendChar(c);
                    }

                    AdvConnection.LogOn(user, spassword);
                }
// Fix indenting!
			Int32 result = 0;
                        String sql = "select id from cgroup"
			// Find the database reference of the thing
			ClearScada.Client.Advanced.IQuery serverQuery = AdvConnection.PrepareQuery(sql, new ClearScada.Client.Advanced.QueryParseParameters());
			ClearScada.Client.Advanced.QueryResult queryResult = serverQuery.ExecuteSync(new ClearScada.Client.Advanced.QueryExecuteParameters());

			if (queryResult.Status == ClearScada.Client.Advanced.QueryStatus.Succeeded || queryResult.Status == ClearScada.Client.Advanced.QueryStatus.NoDataFound)
			{
				if (queryResult.Rows.Count > 0)
				{
					// Found
					IEnumerator<ClearScada.Client.Advanced.QueryRow> e = queryResult.Rows.GetEnumerator();
					while (e.MoveNext())
					{
						result = (Int32)e.Current.Data[0];
					}
				}
			}
			serverQuery.Dispose();
  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

Kan
Ensign Kan
Ensign

Posted: ‎2020-06-29 02:58 AM

In response to sbeadle
0 Likes
0
2975
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2020-06-29 02:58 AM

Hi sbeadle,

 

Thanks heaps for answering my question.

 

I tried your solution and it works! The view in my question refers to the Historic Views defined in Historic Configuration.

 

Thank you again and have a nice day!

 

Kan

  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

BevanWeiss
Spock BevanWeiss
Spock

Posted: ‎2020-06-29 08:42 PM

In response to sbeadle
0 Likes
0
2961
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2020-06-29 08:42 PM

Hey Steve,

 

That's quite some old style enumerator iteration there

while (e.MoveNext())
					{
						result = (Int32)e.Current.Data[0];
					}

 

You're not a fan of the 'foreach'?

There's really so much more power in the .NET stuff around this, like doing processing in parallel..


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

AdamWoodlandToo
Lt. Commander AdamWoodlandToo
Lt. Commander

Posted: ‎2025-02-26 07:26 PM . Last Modified: ‎2025-02-26 07:29 PM

1 Like
0
213
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2025-02-26 07:26 PM . Last Modified: ‎2025-02-26 07:29 PM

For anyone stumbling upon this in 2025, below is the same code (mostly!) as Steve's for Geo SCADA 2023 and PowerShell 5.1 (removed a load of exception handling to simplify things a little)

 

Write-Host "Starting"$(Get-Date) -ForegroundColor Cyan
Add-Type -path "C:\Program Files (x86)\Schneider Electric\ClearSCADA\ClearScada.Client.dll"

$serveraddress = "127.0.0.1"
$port = "5481"
$username = "some_user"
$password = ConvertTo-SecureString "some_password" -AsPlainText -Force

Write-Host "Connecting to Geo SCADA at" $serveraddress":"$port -ForegroundColor Cyan
$node = New-Object ClearScada.Client.ServerNode($serveraddress, $port)
$clearscada = New-Object ClearScada.Client.Simple.Connection("SqlTest")
$clearscada.Connect($node)
Write-Host "Connected. Logging in as" $username "... " -NoNewline
$clearscada.LogOn($username, $password) # In this code I don't actually use this, but its a snippet of something
Write-Host "Success" -ForegroundColor Green

$advclearscada = $clearscada.Server # Creates the advanced connection
$advclearscada.LogOn($username, $password)

$sql = "SELECT Id, FullName FROM CDBObject"
$parseparams = New-Object ClearScada.Client.Advanced.QueryParseParameters
$serverQuery = $advclearscada.PrepareQuery($sql, $parseparams)

$executeparams = New-Object ClearScada.Client.Advanced.QueryExecuteParameters
$queryResult = $serverQuery.ExecuteSync($executeparams)

if ($queryResult.Status -eq "Succeeded") # Not worked out how to do the enumeration in PowerShell for this so hard-coded!
{
    foreach($row in $queryResult.Rows)
    {
        Write-Host $row.data[0] "/" $row.data[1]
    }
}

$serverQuery.Dispose()
$serverQuery = $null

$advclearscada.LogOff()
$advclearscada = $null

$clearscada.LogOff()
$clearscada.Disconnect()
$clearscada = $null

Write-Host "Ended"$(Get-Date) -ForegroundColor Cyan
Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of