Solved

Use of external API in stored procedure?

Posted on 2007-04-02
3
216 Views
Last Modified: 2012-05-05
This test code works in Visual Basic.net. It reads values from some cad-database through their API. ("Spider"-dll is registred on the test machine.) Is it possible to use the API from inside a stored procedure? Please provide sample code... :-)

    Sub Elsa_test()

        Dim spider As Object

        Dim sInterface As String
        Dim KT As Object
        Dim KTnumcols As Integer
        Dim i As Integer

        Const IPADDRESS = "192.168.10.65"
        Const PORT = "5010"
        Const CATALOGUE = "NORDO"


        sInterface = "SpiderX.ActiveX"


        'Sätter upp spiderX objektet / Create "spider" activeX.
        KT = CreateObject(sInterface)
        Call KT.Configure(IPADDRESS, PORT)

        'Testar om databasen går att öppna / Test if ELSA-database could be opened
        If Not KT.OpenTable(86, CATALOGUE, "") Then
            MsgBox("Could not open KT!")
            Exit Sub
        End If

        'Testar att gå till första raden i databasen / Test - move to the first record
        If Not KT.MoveFirst() Then
            MsgBox("Catalogue is empty!")
            Exit Sub
        Else

            Me.TextBox1.AppendText("Dä gick bra att öppna elsa-databasen.")
        End If


        'Läser in antal fält dvs kolumner i ELSA / read number of ELSA-columns
        KTnumcols = KT.GetNumberColumns
        For i = 1 To KTnumcols
            Me.TextBox1.AppendText(KT.GetColumnnamei(i - 1))
        Next

        'Loopar igenom databasen / loop all records
        While KT.GetNext()
            Me.TextBox1.AppendText((KT.GetValuei(1) + " : " + KT.GetValuei(2) + " : " + KT.GetValuei(3)))
        End While

    End Sub
0
Comment
Question by:davidsperling
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
dqmq earned 250 total points
ID: 18836496
No, TSQL is not object languange.  However, you can develop some CLR subroutines based on those objects that are addressable from TSQL.   For example, you can call Elsa_Test from TSQL if you port if over to managed code.
0
 
LVL 4

Author Comment

by:davidsperling
ID: 18836574
Superb! Why didn't I figure it out myself!? Best of all, I have a book that descripes the procedure above right in my knees.

fyi... SQL Server 2005 Stored Procedure Programming In TSQ & .Net by Dejan Sunderic
0
 
LVL 4

Author Comment

by:davidsperling
ID: 18843840
As usual I ran into som security related problems posted here
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_22488676.html

and here

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_22489298.html

Is there a way to make the server Insecure By Default for test purposes!?
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now