Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

SQL Server Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

SQL Server Examples using the Chilkat ActiveX

Click on a category in the left rail to browse SQL Server examples.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Creating Objects

Instances of Chilkat ActiveX components can be created using the sp_OACreate system stored procedure. Here is an example showing how to create an instance of the Zip component:

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

Calling Methods

Methods are called by calling sp_OAMethod. Methods returning a success status return 1 for success and 0 for failure. If a method returns an object, an error is indicated by returning a NULL object reference. Methods returning a string may return an empty string or NULL reference to indicate an error. Check the reference documentation (http://www.chilkatsoft.com/refdoc)

    DECLARE @hr int
    
    -- Instantiate a MailMan object
    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- Call the UnlockComponent method.
    DECLARE @success int
    EXEC sp_OAMethod @mailman, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        PRINT 'Component unlock failed'
        RETURN
      END

SQL Server Methods that Return Long Strings

Some ActiveX methods return strings that are too long for local string variables. See the information at this web page to learn how to handle methods returning long strings in SQL Server.

Important - Do not use NVARCHAR(MAX)

Do not declare local variables as nvarchar(max) for the purpose of receiving the string return value of a function, or for getting an ActiveX object's property. Using nvarchar(max) does not work with ActiveX. Instead, declare local string variables as nvarchar(4000). If the returned string is likely to exceed 4000 chars in length, then use temp tables instead of local variables


Setting Properties

Set properties by calling sp_OASetProperty:

    EXEC sp_OASetProperty @ftp, 'Port', 990
    EXEC sp_OASetProperty @ftp, 'Hostname', 'ftp.chilkatsoft.com'

Getting Properties

Properties are retrieved by calling sp_OAGetProperty. Local variables can hold a maximum of 4000 characters. To fetch property values that may contain longer strings, such as LastErrorText or SessionLog, use a temporary table, as shown below:

	DECLARE @iTmp0 int
	DECLARE @sTmp0 nvarchar(4000)

	EXEC sp_OAGetProperty @mailman, 'SmtpPort', @iTmp0 OUT
	PRINT @iTmp0

	EXEC sp_OAGetProperty @mailman, 'SmtpHost', @sTmp0 OUT
	PRINT @sTmp0

	-- Fetch a longer property string into a temp table:
	DECLARE @tmp TABLE (sessionLog ntext)
	INSERT INTO @tmp EXEC sp_OAGetProperty @ftp, 'SessionLog'

Last Error Information

When a method call returns with a failure status, information about the error is available in the LastErrorText property. This property also contains information about the method call on success, allowing you to visually verify that an operation proceeded as you expected. (For example, was SSL actually used for an IMAP connection?)

    EXEC sp_OAMethod @ftp, 'PutFile', @success OUT, 'localFilename.txt', 'remoteFilename.txt'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @ftp, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
      END
 

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