![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Example: Http.ExtractMetaRefreshUrl methodDemonstrates the
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @success int SELECT @success = 0 DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Sample HTML with a META refresh. -- <!DOCTYPE html> -- <html lang="en"> -- <head> -- <meta charset="utf-8" /> -- <meta http-equiv="refresh" content="5; url=https://example.com" /> -- <title>Meta Refresh Redirect</title> -- </head> -- <body> -- <p>Redirecting to example.com in 5 seconds�</p> -- </body> -- </html> DECLARE @sb int EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sb OUT DECLARE @bCrlf int SELECT @bCrlf = 1 EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '<!DOCTYPE html>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '<html lang="en">', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '<head>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, ' <meta charset="utf-8" />', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, ' <meta http-equiv="refresh" content="5; url=https://example.com" />', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, ' <title>Meta Refresh Redirect</title>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '</head>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '<body>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, ' <p>Redirecting to example.com in 5 seconds�</p>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '</body>', @bCrlf EXEC sp_OAMethod @sb, 'AppendLine', @success OUT, '</html>', @bCrlf DECLARE @url nvarchar(4000) EXEC sp_OAMethod @sb, 'GetAsString', @sTmp0 OUT EXEC sp_OAMethod @http, 'ExtractMetaRefreshUrl', @url OUT, @sTmp0 EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 = 0 BEGIN PRINT 'The HTML has no META refresh tag.' END ELSE BEGIN PRINT 'META refresh URL: ' + @url END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sb END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.