Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > SQL Server Call HTTP URL เรียกใช้งาน URL Website จาก Stored Procedure



 
Clound SSD Virtual Server

SQL Server Call HTTP URL เรียกใช้งาน URL Website จาก Stored Procedure

SQL Server Call HTTP URL เรียกใช้งาน URL Website จาก Stored Procedure เทคนิคการใช้ SQL Server Call URL เรียกใช้งาน URL ของ Website จาก Stored Procedure ของ SQL Server สามารถประยุกต์การใช้งานกับ Function ต่างๆ เช่น การเรียกให้ URL ทำงานเมื่อ Stored Procedure ทำงานเสร็จ และประยุกต์กับการแจจ้งเตือนด้วยการตั้ง Job Schedule ได้



SQL Server Stored Procedure Call URL Website


ให้สร้าง Stored Procedure ดังนี้

Code
CREATE PROCEDURE [dbo].[HTTPWebRequest]( @sUrl VARCHAR(500))
AS

	DECLARE		@oObject	INT;
	DECLARE		@oHr		INT;
	DECLARE		@sMsg	VARCHAR(255)


	EXEC @oHr = sp_OACreate 'MSXML2.ServerXMLHttp', @oObject OUT
	IF @oHr <> 0 BEGIN  RAISERROR('sp_OACreate MSXML2.ServerXMLHttp.3.0 failed', 16,1) RETURN END


	EXEC @oHr = sp_OAMethod @oObject, 'open', NULL, 'POST', @sUrl, False
	IF @oHr <>0 BEGIN SET @sMsg = 'sp_OAMethod Open failed' GOTO EH END


	EXEC @oHr = sp_OAMethod @oObject, 'setRequestHeader', NULL, 'Content-Type',
	'application/x-www-form-urlencoded'
	IF @oHr <>0 BEGIN SET @sMsg = 'sp_OAMethod setRequestHeader failed' GOTO EH END


	EXEC @oHr = sp_OAMethod @oObject, SEND, NULL, ''
	IF @oHr <> 0 BEGIN SET @sMsg = 'sp_OAMethod Send failed' GOTO EH END

	EXEC @oHr = sp_OADestroy @oObject
	RETURN;
EH:
	EXEC @oHr = sp_OADestroy @oObject
		RAISERROR(@sMsg, 16, 1)
	RETURN;


ทดสอบการทำงาน
EXEC 'https://www.thaicreate.com/notify.php';

กรณีที่ Error

1

Error
Msg 15281, Level 16, State 1, Procedure sp_OACreate, Line 1
SQL Server blocked access to procedure 'sys.sp_OACreate' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', search for 'Ole Automation Procedures' in SQL Server Books Online.
Msg 15281, Level 16, State 1, Procedure sp_OAMethod, Line 1
SQL Server blocked access to procedure 'sys.sp_OAMethod' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', search for 'Ole Automation Procedures' in SQL Server Books Online.
Msg 15281, Level 16, State 1, Procedure sp_OAMethod, Line 1
SQL Server blocked access to procedure 'sys.sp_OAMethod' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', search for 'Ole Automation Procedures' in SQL Server Books Online.
Msg 15281, Level 16, State 1, Procedure sp_OAMethod, Line 1
SQL Server blocked access to procedure 'sys.sp_OAMethod' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', search for 'Ole Automation Procedures' in SQL Server Books Online.
Msg 15281, Level 16, State 1, Procedure sp_OADestroy, Line 1
SQL Server blocked access to procedure 'sys.sp_OADestroy' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', search for 'Ole Automation Procedures' in SQL Server Books Online.


SQL
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO

2

ทดสอบการทำงานใหม่

3

ทำงานสำเร็จแล้ว

สามารถตั้ง Job Schedule ได้ เช่น

SQL Server Call Execute URL Website

วิธีการสร้าง Job Schedule เพื่อเรียกใช้งาน

SQL Server Call Execute URL Website

วิธีการสร้าง Job Schedule เพื่อเรียกใช้งาน

SQL Server Call Execute URL Website

วิธีการสร้าง Job Schedule เพื่อเรียกใช้งาน

SQL Server Call Execute URL Website

วิธีการสร้าง Job Schedule เพื่อเรียกใช้งาน

SQL Server Call Execute URL Website

วิธีการสร้าง Job Schedule เพื่อเรียกใช้งาน







   
Share
Bookmark.   

  By : TC Admin
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2019-04-25
  Download : No files
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่