Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

SQL Server Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(SQL Server) MaxMind IPv4 Geolocation Lookup

Demonstrates how to lookup Geolocation data for an IPv4 address using the MaxMind GeoIP2 Precision Web Service.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    -- This example requires the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @http, 'Login', 'MAXMIND_ACCOUNT_ID'
    EXEC sp_OASetProperty @http, 'Password', 'MAXMIND_LICENSE_KEY'
    EXEC sp_OASetProperty @http, 'Accept', 'application/json'

    -- Lookup an IPv4 address: 149.250.207.170  (this was a randomly chosen address)
    DECLARE @jsonStr nvarchar(4000)
    EXEC sp_OAMethod @http, 'QuickGetStr', @jsonStr OUT, 'https://geoip.maxmind.com/geoip/v2.1/country/149.250.207.170'
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OASetProperty @json, 'EmitCompact', 0
    DECLARE @success int
    EXEC sp_OAMethod @json, 'Load', @success OUT, @jsonStr

    EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    -- Sample output:
    -- Use this online tool to generate parsing code from sample JSON: 
    -- Generate Parsing Code from JSON

    -- {
    --   "continent": {
    --     "code": "EU",
    --     "geoname_id": 6255148,
    --     "names": {
    --       "ja": "?????",
    --       "pt-BR": "Europa",
    --       "ru": "??????",
    --       "zh-CN": "??",
    --       "de": "Europa",
    --       "en": "Europe",
    --       "es": "Europa",
    --       "fr": "Europe"
    --     }
    --   },
    --   "country": {
    --     "is_in_european_union": true,
    --     "iso_code": "DE",
    --     "geoname_id": 2921044,
    --     "names": {
    --       "fr": "Allemagne",
    --       "ja": "????????",
    --       "pt-BR": "Alemanha",
    --       "ru": "????????",
    --       "zh-CN": "??",
    --       "de": "Deutschland",
    --       "en": "Germany",
    --       "es": "Alemania"
    --     }
    --   },
    --   "maxmind": {
    --     "queries_remaining": 49999
    --   },
    --   "registered_country": {
    --     "is_in_european_union": true,
    --     "iso_code": "DE",
    --     "geoname_id": 2921044,
    --     "names": {
    --       "es": "Alemania",
    --       "fr": "Allemagne",
    --       "ja": "????????",
    --       "pt-BR": "Alemanha",
    --       "ru": "????????",
    --       "zh-CN": "??",
    --       "de": "Deutschland",
    --       "en": "Germany"
    --     }
    --   },
    --   "traits": {
    --     "ip_address": "149.250.207.170"
    --   }
    -- }
    -- 
    -- 
    DECLARE @continentCode nvarchar(4000)

    DECLARE @continentGeoname_id int

    DECLARE @continentNamesJa nvarchar(4000)

    DECLARE @continentNamesPt_BR nvarchar(4000)

    DECLARE @continentNamesRu nvarchar(4000)

    DECLARE @continentNamesZh_CN nvarchar(4000)

    DECLARE @continentNamesDe nvarchar(4000)

    DECLARE @continentNamesEn nvarchar(4000)

    DECLARE @continentNamesEs nvarchar(4000)

    DECLARE @continentNamesFr nvarchar(4000)

    DECLARE @countryIs_in_european_union int

    DECLARE @countryIso_code nvarchar(4000)

    DECLARE @countryGeoname_id int

    DECLARE @countryNamesFr nvarchar(4000)

    DECLARE @countryNamesJa nvarchar(4000)

    DECLARE @countryNamesPt_BR nvarchar(4000)

    DECLARE @countryNamesRu nvarchar(4000)

    DECLARE @countryNamesZh_CN nvarchar(4000)

    DECLARE @countryNamesDe nvarchar(4000)

    DECLARE @countryNamesEn nvarchar(4000)

    DECLARE @countryNamesEs nvarchar(4000)

    DECLARE @maxmindQueries_remaining int

    DECLARE @registered_countryIs_in_european_union int

    DECLARE @registered_countryIso_code nvarchar(4000)

    DECLARE @registered_countryGeoname_id int

    DECLARE @registered_countryNamesEs nvarchar(4000)

    DECLARE @registered_countryNamesFr nvarchar(4000)

    DECLARE @registered_countryNamesJa nvarchar(4000)

    DECLARE @registered_countryNamesPt_BR nvarchar(4000)

    DECLARE @registered_countryNamesRu nvarchar(4000)

    DECLARE @registered_countryNamesZh_CN nvarchar(4000)

    DECLARE @registered_countryNamesDe nvarchar(4000)

    DECLARE @registered_countryNamesEn nvarchar(4000)

    DECLARE @traitsIp_address nvarchar(4000)

    EXEC sp_OAMethod @json, 'StringOf', @continentCode OUT, 'continent.code'
    EXEC sp_OAMethod @json, 'IntOf', @continentGeoname_id OUT, 'continent.geoname_id'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesJa OUT, 'continent.names.ja'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesPt_BR OUT, 'continent.names.pt-BR'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesRu OUT, 'continent.names.ru'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesZh_CN OUT, 'continent.names.zh-CN'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesDe OUT, 'continent.names.de'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesEn OUT, 'continent.names.en'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesEs OUT, 'continent.names.es'
    EXEC sp_OAMethod @json, 'StringOf', @continentNamesFr OUT, 'continent.names.fr'
    EXEC sp_OAMethod @json, 'BoolOf', @countryIs_in_european_union OUT, 'country.is_in_european_union'
    EXEC sp_OAMethod @json, 'StringOf', @countryIso_code OUT, 'country.iso_code'
    EXEC sp_OAMethod @json, 'IntOf', @countryGeoname_id OUT, 'country.geoname_id'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesFr OUT, 'country.names.fr'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesJa OUT, 'country.names.ja'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesPt_BR OUT, 'country.names.pt-BR'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesRu OUT, 'country.names.ru'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesZh_CN OUT, 'country.names.zh-CN'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesDe OUT, 'country.names.de'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesEn OUT, 'country.names.en'
    EXEC sp_OAMethod @json, 'StringOf', @countryNamesEs OUT, 'country.names.es'
    EXEC sp_OAMethod @json, 'IntOf', @maxmindQueries_remaining OUT, 'maxmind.queries_remaining'
    EXEC sp_OAMethod @json, 'BoolOf', @registered_countryIs_in_european_union OUT, 'registered_country.is_in_european_union'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryIso_code OUT, 'registered_country.iso_code'
    EXEC sp_OAMethod @json, 'IntOf', @registered_countryGeoname_id OUT, 'registered_country.geoname_id'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesEs OUT, 'registered_country.names.es'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesFr OUT, 'registered_country.names.fr'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesJa OUT, 'registered_country.names.ja'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesPt_BR OUT, 'registered_country.names.pt-BR'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesRu OUT, 'registered_country.names.ru'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesZh_CN OUT, 'registered_country.names.zh-CN'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesDe OUT, 'registered_country.names.de'
    EXEC sp_OAMethod @json, 'StringOf', @registered_countryNamesEn OUT, 'registered_country.names.en'
    EXEC sp_OAMethod @json, 'StringOf', @traitsIp_address OUT, 'traits.ip_address'

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json


END
GO

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.