아래의 주어진 절차를 사용하여 SQL Server에서 SMS를 보내고 있습니다. 어제 밤까지 잘 작동합니다.SQL Server 2008의 sp_OAMethod를 통한 SMS 전송 문제
하지만, 오늘은 무엇입니까 다음과 같은 오류 : -
-2146697212 Msg 50000, Level 16, State 1, Procedure pr_SendSmsSQL, Line 61
sp_OAMethod Send FAILED!
내가 그것을 주어진 메시지 아래 저를 보여줍니다 다음 정확한 오류를 알고 "sp_OAGetErrorInfo"를 추가 : -
Error Source Description
msxml3.dll Unable to connect to the target server.
방법 안내하시기 바랍니다 이 문제를 해결합니다. 동일한 코드가 다른 SQL Server에서 제대로 실행되고 있습니다.
저장 프로 시저 코드 : -
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/*
Purpose : To send SMS from SQL.
declare @sResponse as varchar(1000)
exec pr_SendSmsSQL '1234567891','This Is a Test SMS From SQL Server - Regards, BSethi24',''
print @sResponse
*/
ALTER Procedure [dbo].[pr_SendSmsSQL]
@MobileNo varchar(12),
@smstext as varchar(300),
@sResponse varchar(1000) OUT
as
BEGIN
Declare @iReq int,@hr int
Declare @sUrl as varchar(500)
DECLARE @errorSource VARCHAR(8000)
DECLARE @errorDescription VARCHAR(8000)
-- Create Object for XMLHTTP
EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP', @iReq OUT
print @hr
if @hr <> 0
Raiserror('sp_OACreate Microsoft.XMLHTTP FAILED!', 16, 1)
set @sUrl='http://122.22.12.12/smsportal/sendsms.aspx?usr=test&pass=test&senderid=BSethi24&mobileno=#MobNo#&messagetext=#Msg#'
set @sUrl=REPLACE(@sUrl,'#MobNo#',@MobileNo)
set @sUrl=REPLACE(@sUrl,'#Msg#',@smstext)
print @sUrl
-- sms code start
EXEC @hr = sp_OAMethod @iReq, 'Open', NULL, 'GET', @sUrl, true
print @hr
if @hr <> 0
Raiserror('sp_OAMethod Open FAILED!', 16, 1)
EXEC @hr = sp_OAMethod @iReq, 'send'
select @iReq
print @hr
if @hr <> 0
Begin
EXEC sp_OAGetErrorInfo @iReq, @errorSource OUTPUT, @errorDescription OUTPUT
SELECT [Error Source] = @errorSource, [Description] = @errorDescription
Raiserror('sp_OAMethod Send FAILED!', 16, 1)
end
else
Begin
EXEC @hr = sp_OAGetProperty @iReq,'responseText', @sResponse OUT
print @hr
insert into s_SmsLog (Id,Mobile_No,SMSText,SMSResponse,Created_By,Created_Date,Modified_By,Modified_Date)
values(0,@MobileNo,@smstext,@sResponse,'System',GETDATE(),null,null)
End