Solved

Use of external API in stored procedure?

Posted on 2007-04-02
3
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Move SQL 2005 Express to Server 2012R2 19 166
Query to Add Late Tolerance 10 82
date diff with Fiscal Calendar 4 76
What is this datetime? 1 29
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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