Execute SQL Stored Procedure Query on Wonderware Archestra and Transfer Data

preview_player
Показать описание
Code SQL Adding Procedure:
CREATE PROCEDURE spDatabase
AS
BEGIN
SELECT column1, column2, column3
FROM tblDatabase
END;
GO

Code Stored Procedure:
USE [TestDatabase]
GO
/****** Object: StoredProcedure [dbo].[spDatabase] Script Date: 10/14/2023 5:46:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[spDatabase]
as
begin
set nocount on
set quoted_identifier off;
insert into tblDatabase
(DatabaseCPU_Load , DatabaseCPU_Ave, Machine_Temperature)
values
end

CODE Archestra Object:
dim dt as System.DateTime;
dim SQLCONNECTION as System.Data.SqlClient.SqlConnection;
dim SQLCommand as System.Data.SqlClient.SqlCommand;
dim sDBConnStr as string;

dim sQuery as string;
dim RecordAffected as integer;

sDBConnStr = "Server=DESKTOP-76IUJ1R;Database=TestDatabase;Integrated Security=True";
SQLCONNECTION = New System.Data.SqlClient.SqlConnection (sDBConnStr);
SQLCONNECTION.Open();

sQuery = "spDatabase";

SQLCommand = new System.Data.SqlClient.SqlCommand (sQuery, SQLCONNECTION);
SQLCommand.CommandType = System.Data.CommandType.StoredProcedure;

LogMessage ("Insert About to Execute " + SQLCommand);
RecordAffected = SQLCommand.ExecuteNonQuery();
SQLCONNECTION.Dispose();
LogMessage ("Insert Submitted....Records Affected: " + Text(RecordAffected, "#"));
Рекомендации по теме
Комментарии
Автор

Thanks Charlie - I did this YEARS ago and just needed a quick refresher.

TheHeaterdude
Автор

I was done. resolve by correction connection string to right >> sDBConnStr =

spk
Автор

please trainng first step create Object "Trial" I 'm beginer

spk
welcome to shbcf.ru