Software Archive
Read-only legacy content

DLL for ASPs

rahzan
New Contributor I
710 Views
Has anyone produced a DLL for use in an ASP?
I understand that the functions return types must be Variants. Since I have not done this before, If anyone has a template for doing this I will much appreciate getting it.

Thanks, Tim H
0 Kudos
3 Replies
Intel_C_Intel
Employee
710 Views
Hi Tim,

ASP pages use VBScript (which is a subset of the full VB language). I'm not a VBScript expert, but as far as I can tell VBScript does not support calling a routine in a DLL. If anyone knows better..., please respond.

Regards,
Leo
0 Kudos
rahzan
New Contributor I
710 Views
Have a Look at :
http://p2p.wrox.com/archive/beginning_asp/2001-05/13.asp

Which amounts to the following code:
ASP Code (generic class works fine through a sub)
set Generic = Server.CreateObject("MYOBJ.Generic")
Generic.UserID = Request.Form("userid")
Generic.Password = Request.Form("pwd")

Generic.LogIn
session("agency_id") = Generic.AgencyID
session("access_level") = Generic.AccessLevel

set Client = Server.CreateObject("MYOBJ.Client")
Client.UserID = Request.Form("userid")
Client.Password = Request.Form("pwd")
Client.AgencyID = cint(session("agency_id"))
myagency = cint(session("agency_id"))
session("mycontract") = Client.FetchContractor(myagency)

VB DLL:
Public Function FetchContractor(intAgencyID As Integer) As Variant
On Error GoTo ErrorHandler

'Open connection to database
ConnectRstToDatabase

With rst
.Open "Exec SP_ContractorFetchByAgency " & intAgencyID & " "
If .EOF = False Then
FetchContractor = .GetRows
End If
End With

'Clean up and exit
CleanUpResources

Exit Function

ErrorHandler:
Call RaiseError(Err.Number, "FetchContractor", Err.Description)
End Function
0 Kudos
Intel_C_Intel
Employee
710 Views
AFAIK, Leo is correct, ASP doesn't support classic DLLs, just COM objects. The reponses posted at the link Tim gave all seem to be focused on VB ActiveX DLLs (the hint is the Server.CreateObject calls) which are not which are not plain old DLLs.

With CVF, create a COM object using a dual interface and only VARIANT args. That should get you going where you want.

John
0 Kudos
Reply