Link to home
Start Free TrialLog in
Avatar of shayne23d
shayne23d

asked on

calling a vb dll function from an asp page.

Hi I have a function in a activex dll that is registered.
The function is a log in function and it takes two strings, one as name and one as password.

I am making the call from an asp page . Here it is

<%
       dim strName
      dim strPass
      strName = request.form("Name")
      strPass = request.form("pass")
      strPass = CStr(strPass)
      strName = Cstr(strName)
      
      dim objUSSC
      set objUSCC = server.CreateObject("sports.USSC")
      objUSSC.login (strName strPass)
      
%>

I get this error
Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/sport/Default.asp, line 31, column 32
objUSSC.login (strName, strPass)

Thanks

Avatar of Brad Dobyns, CSM
Brad Dobyns, CSM
Flag of United States of America image

Try this:

Call objUSSC.login(strName, strPass)

Brad
Avatar of shayne23d
shayne23d

ASKER

Ok I tried that and I got this error
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
Or if that diesn't work try this:

objUSSC.login strName, strPass (without parenthases)

Brad
Usually, when receving the message "Cannot use parentheses when calling a Sub", all you'll have to do is remove the parentheses.

Try this instead:
objUSSC.login strName, strPass

Generally, parentheses are only necessary around the parameters sent to a Function which will return a value to the point at which it was called.
Little late wendelina... :o)

Brad
tried that and I get  the error
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/sport/Default.asp, line 31


I am calling a function as boolean that returns true or false
Did you register the DLL on your server?

Brad
yes i did. Is my call to cast the varaint as string correct?
could that be the problem?

That could be it if the two methods I mentioned didn't work and the DLL is registered. Is the type Bool or is the type Sting?

Brad
the type is boolean
Are you using toBool or asBool?

Brad
as boolean
And is .login a correct method of the class USSC?

Brad
yes it is.  by the way thanks for the work yo uare doing
any other thoughts?
You are welcome. :o)

Have you tested the function to make sure it will accept the two values and return the value "true" or "false"?

Brad
yes Before moving it over to a dll I tested it as vb project and it did just fine.

The error code is what has me stumped. If the DLL is registered and you have tested the function beforehand, and you have created the object correctly and made a call to the function or method within the DLL... What the heck is the problem?

Brad
i have not created any get  let methods. i have only created a public function login.
Do i need to write get and let methods for asp to work.
it seems that I should be able to call a public fucntion and pass the varaibles from the asp to the dll
I am not worried about incapsulation I am just trying to get the aps and object to talk
Here is the vb functionPublic Function login(ByVal strName As String, ByVal strPass As String) As Boolean

   Dim strN As String
   Dim strP As String
   strN = strName
   Debug.Print strN
   Dim strCheckN As String
   Dim strCheckP As String
   
   strP = strPass
   
   
   Dim rs As ADODB.Recordset
   
   Dim cn As ADODB.Connection
   Dim cmd As ADODB.Command
   
   Set cn = New ADODB.Connection
   cn.CONNECTIONSTRING = CONNECTIONSTRING
   cn.Open
   
   Set cmd = New ADODB.Command
   cmd.ActiveConnection = cn
   cmd.CommandText = "select * from customer where customer_Login = " & "'" & strN & "'"
   
   
   cmd.CommandType = adCmdText
   
   Set rs = New ADODB.Recordset
   rs.Open cmd, , adOpenKeyset, adLockOptimistic
   'strCustID = rs.Fields("customer_ID").Value
   strCheckN = rs.Fields("customer_Login").Value
   strCheckP = rs.Fields("customer_Email").Value
   
   
   
   
   
   strP = Trim$(strP)
   strN = Trim$(strN)
   strCheckN = Trim$(strCheckN)
   strCheckP = Trim$(strCheckP)
   
   strPassword = Trim$(strPassword)
   If (strP = strCheckP) Then
   strCustID = rs.Fields("customer_ID").Value
   Debug.Print strCustID
   Debug.Print "You have logged in"
   
      login = True
     
   Else
      login = False
   End If
   

End Function
ASKER CERTIFIED SOLUTION
Avatar of Brad Dobyns, CSM
Brad Dobyns, CSM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
doh     Man oh man
thanks
Boy, do I feel stupid as hell...TGIF!!!!

Brad
Thanks for the points!! Good Luck!

Brad