?
Solved

Use of external API in stored procedure?

Posted on 2007-04-02
3
Medium Priority
?
225 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 1000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

862 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