Solved

Use of external API in stored procedure?

Posted on 2007-04-02
3
213 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

14 Experts available now in Live!

Get 1:1 Help Now