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]
(@DatabaseCPU_Load float , @DatabaseCPU_Ave float, @Machine_Temperature float)
as
begin
set nocount on
set quoted_identifier off;
insert into tblDatabase
(DatabaseCPU_Load , DatabaseCPU_Ave, Machine_Temperature)
values
(@DatabaseCPU_Load , @DatabaseCPU_Ave, @Machine_Temperature);
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;
SQLCommand.Parameters.Add ("@DatabaseCPU_Load", System.Data.SqlDbType.Float);
SQLCommand.Parameters.Add ("@DatabaseCPU_Ave", System.Data.SqlDbType.Float);
SQLCommand.Parameters.Add ("@Machine_Temperature", System.Data.SqlDbType.Float);
SQLCommand.Parameters ("@DatabaseCPU_Load").Value = WinPlatform_001.CPULoad;
SQLCommand.Parameters ("@DatabaseCPU_Ave").Value=WinPlatform_001.CPULoadAvg;
SQLCommand.Parameters ("@Machine_Temperature").Value = Me.Temperature;
LogMessage ("Insert About to Execute " + SQLCommand);
RecordAffected = SQLCommand.ExecuteNonQuery();
SQLCONNECTION.Dispose();
LogMessage ("Insert Submitted....Records Affected: " + Text(RecordAffected, "#"));
Watch video Execute SQL Stored Procedure Query on Wonderware Archestra and Transfer Data online without registration, duration hours minute second in high quality. This video was added by user Charlie Cabreros 14 October 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,531 once and liked it 15 people.