Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Chilkat SQL Server Stored Procedure Quick Start TutorialDownload and Install the Chilkat ActiveX Component(s)Download and install whichever ActiveX components you will be using. Direct download links are provided below. You may install each .msi on the server directly, or you may install on a separate computer and copy DLLs to the SQL Server system. Each DLL is an ActiveX that needs to be registered using regsvr32.exe. The Chilkat DLLs are installed under "Program Files/Chilkat Software Inc/<product_name>/..." Creating ObjectsInstances 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.Zip2', @zip OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END Calling MethodsMethods 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 MailMan2 object
DECLARE @mailman int
EXEC @hr = sp_OACreate 'Chilkat.MailMan2', @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
Setting PropertiesSet properties by calling sp_OASetProperty:
EXEC sp_OASetProperty @ftp, 'Port', 990
EXEC sp_OASetProperty @ftp, 'Hostname', 'ftp.chilkatsoft.com'
Getting PropertiesProperties 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 InformationWhen 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
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2009 Chilkat Software, Inc. All Rights Reserved.