Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a constant in DLL file? 2

Status
Not open for further replies.

Chopstik

Technical User
Oct 24, 2001
2,180
US
I have created a .dll file that is being used in my ASP application. I have some constants that are module level in my .dll file that I am told by my boss he wants used in the asp app. So now, I'm wondering if it is possible to reference them in my asp script and, if so, how? I hope this makes sense. If you need to see some of the code, please let me know. Thanks for any help. Insanity is merely a state of mind while crazy people have a mind of their own.
 
A sample from the .dll:

Option Explicit
Const ActiveConn As String = 'active connection string info here

'These are constants for drop downs, etc.
Const vbOptionType As Integer = 1
Const vbObligType As Integer = 2

Public Function DropDown(Choice As Integer) As ADODB.Recordset
Dim strSQL
Select Case Choice

Case 1
strSQL = "SELECT optn_ty_cd, optn_ty_desc FROM T_DOC_OPTN_TY"

Case 2
strSQL = "SELECT oblig_ty_cd, oblig_ty_desc FROM T_OBLIG_TY"

Case Else
strSQL = "Not a valid screen"

End Select

Set DropDown = GetData(strSQL)
End Function

Then, in my ASP page, I need to able to reference the constant name (which would be the integer parameter then passed down to the function). I'm at something of a loss here as to how to even begin this part. According to the boss, I should be able reference that by declaring it in the VBScript, but must just have brain lock b/c I'm not seeing it. Thanks for any help! Insanity is merely a state of mind while crazy people have a mind of their own.
 
Hi Chopstik,

In your DLL, add an ENUM collection. What this will do is reveal these constants in the way you want to use it. Basically, it will (in InterDev) pop up a selection box when you type the DropDown() function. Try doing something like this in the DLL code:

Option Explicit
Const ActiveConn As String = 'active connection string info here

Enum Choice
vbOptionType = 1
vbObligType = 2
End Enum

Public Function DropDown(Choice As Integer) As ADODB.Recordset
Dim strSQL
Select Case Choice

Case 1
strSQL = "SELECT optn_ty_cd, optn_ty_desc FROM T_DOC_OPTN_TY"

Case 2
strSQL = "SELECT oblig_ty_cd, oblig_ty_desc FROM T_OBLIG_TY"

Case Else
strSQL = "Not a valid screen"

End Select

Set DropDown = GetData(strSQL)
End Function



Cheers,

Gorkem.






 
Gorkem, thanks for the info. Had never used Enum before, so that is a nice tool. I am still unable to reference this in InterDev, however, and not sure why. I have tried a couple of different ways to retrieve it, yet it still doesn't appear to recognise it. Any idea why? Partial code that I am using to reference it is as follows:

<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>Options Summary</TITLE>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;
Code:
Link4
style1.css&quot;>
</HEAD>
<BODY>
<%
dim objCOM, strSQL, rs, i, rsTest, objConst
dim OptionID, DocID, EffDt, NotifyDt, OptionNotes, ActionTaken, ExerciseDt, ActionDt
dim AlarmDt, RenewalOption, MonthNextOption, LastModID, LastModDt, OptionType

set objCOM = server.CreateObject(&quot;
Code:
Link4D.Link4
&quot;)
set rsTest = objCOM.DropDown(cint(vbOptionType))
%>
<H2>OPTIONS</H2>
<FORM name=frmOptions method=&quot;POST&quot; action=&quot;Option.asp?screen=<%=Request.QueryString(&quot;screen&quot;)%>&id=<%=Request.QueryString(&quot;id&quot;)%>&OptionID=<%=Request.QueryString(&quot;OptionID&quot;)%>&quot;>
<TABLE width=700>
<tr>
<td width=175><b>Option Type</b></td>
<td width=175><b>Document ID</b></td>
<td width=175><b>Renewal Option</b></td>
<td width=175><b>Next Option Month</b></td>
</tr>
<tr>
<td><select id=&quot;SelOptType&quot; name=&quot;SelOptType&quot;>
<%
while not rsTest.EOF
if OptionType = rsTest.Fields(&quot;optn_ty_cd&quot;) then
Response.Write &quot;<option selected>&quot; & rsTest.Fields(&quot;optn_ty_cd&quot;) & &quot;</option>&quot;
else
Response.Write &quot;<option>&quot; & rsTest.Fields(&quot;optn_ty_cd&quot;) & &quot;</option>&quot;
end if
rsTest.MoveNext
wend
%>
</select></td>
<td><input type=&quot;text&quot; name=&quot;DocID&quot; value=&quot;<%=DocID%>&quot;></td>
<td><input maxlength=255 name=&quot;RenewalOption&quot; value=&quot;<%=RenewalOption%>&quot;></td>
<td><input type=&quot;text&quot; name=&quot;MonthNextOption&quot; value=&quot;<%=MonthNextOption%>&quot;></td>
</tr>
<tr></tr><tr></tr><tr></tr>


Thanks!
Insanity is merely a state of mind while crazy people have a mind of their own.
 
Thanks, figured out the last piece of the problem. The DropDown function parameter should read like this:

Public Function DropDown(Choice As Choice) As ADODB.Recordset
Dim strSQL
Select Case Choice

Case 1
strSQL = &quot;SELECT optn_ty_cd, optn_ty_desc FROM T_DOC_OPTN_TY&quot;

Case 2
strSQL = &quot;SELECT oblig_ty_cd, oblig_ty_desc FROM T_OBLIG_TY&quot;

Case Else
strSQL = &quot;Not a valid screen&quot;

End Select

Set DropDown = GetData(strSQL)
End Function

Didn't realise that Enum creates a new data type, but that fixed the issue. Thanks again for all of your help! Insanity is merely a state of mind while crazy people have a mind of their own.
 
Hi Chopstik,

Yeah.. sorry.. I wrote that on the fly so I, as always, there are a few bugs.. Cudo's on fixing my mistake.

Cheers,

G.
 
Well, actually, I have another issue/question now. ;-) I now get the list of variable options in InterDev when I call the DropDown function, but when I enter in the one that I want to use, no recordset is returned. I determined what variable is being passed in the parameter, and it is a zero each time. It seems like it is ignoring the parameter and simply entering an empty string/zero each time. Any idea on why this would be occurring? Perhaps I'm missing something (well, ok, very likely I'm missing something), but not sure what... still researching... Insanity is merely a state of mind while crazy people have a mind of their own.
 
Hey Chopstik,

Everything looks ok.. however, I cannot really test it since I don't have VB installed on this machine.. Your best bet is to use test out the CLASS by creating a small VB program with it.. make sure you don't declare the actuall DLL, but instead use the CLASS so you can debug it.

Cheers,

G.
 
Yep, am working on that now... If I can't find an answer shortly, I'm going to put it aside for now and come back to it later. If I find one, I'll let you know. Thanks again for your help! :) Insanity is merely a state of mind while crazy people have a mind of their own.
 
The reason you get no recordset is InterDev although reading the DLL headers to offer up the intellisense while developing does not actually know what the option Values are as integers.

Adding the DLL as a reference to the ASP solution should sort that out, passing the integer value 1 I assume returns the correct result?
 
Simpleton,

Passing the integer value 1 does return the correct result. So I made the change you suggested by adding the DLL as a reference in the ASP application and now it works! Perfect, and thank you VERY much!
Insanity is merely a state of mind while crazy people have a mind of their own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top