Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

SMS Procedure in SQL Server 2008(Urgent)

$
0
0
I have created following procedure for sending SMS
earlier it was working fine suddenly it has stop working
what is the problem can any body guide me urgently it has hamper my work

CREATE procedure [dbo].[SendSmsSQL]
@MobileNo varchar(12),
@smstext as nvarchar(300)
--@sResponse varchar(1000) OUT
as
BEGIN
Declare @iReq int
Declare @hr int
Declare @sUrl as varchar(500)
DECLARE @errorSource VARCHAR(8000)
DECLARE @errorDescription VARCHAR(8000)
Declare @sResponse varchar(1000)
-- ysf inserted

--set @smstext ='Welcome to Dhoot Hospital U r registered under Dr. xyz wide Reg.No. 1516121514 If U need any assistance contact help desk or Call 9225333162 Thank you'

-- Create Object for XMLHTTP
--EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP',@iReq OUT
exec @hr= sp_OACreate 'Msxml2.ServerXMLHTTP.3.0',@iReq OUT
-- print @hr

if @hr <> 0
Raiserror('sp_OACreate Microsoft.XMLHTTP FAILED!', 16, 1)

-- set @sUrl ='http://bulksms.solutions.com/api/mt/SendSMS?APIKey=584705-0c41-4e8b-65248-a1a8a6f8eb61&senderid=WEBSMS&channel=1&DCS=0&flashsms=0&number=#MobNo#&text=#Msg#&route=1'
set @sUrl ='http://bulksms.vrudheesolutions.com/api/mt/SendSMS?APIKey=9547kij-0c41-84lok-8a93-a1a8a6f8eb61&senderid=xyz&channel=2&DCS=0&flashsms=0&number=#MobNo#&text=#Msg#&route=1'
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'
print @hr
select @iReq

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 OUTPUT
print @hr
end
end

Viewing all articles
Browse latest Browse all 2918


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>