Solved

Cannot pass parentheses when calling function

Posted on 2002-07-11
8
514 Views
Last Modified: 2012-11-19
This is my asp code used to call the function
<%
     Dim user    
     set user = CreateObject("survey.dbConnect")
     user.displayData("SD","Sekolah","BJC0000")          
%>

Thi sis my function is used to create dll file

Public Function displayData(Optional db As String, Optional tb As String, Optional userName As String)
   
    Dim sqlQry As String
   
    getConnection (db)
    sqlQry = "select *from " & tb & " where kod = " & userName
    Set objRs = New ADODB.Recordset
    objRs.Open sqlQry, objConn
    objRs.MoveFirst
    lastModify = objRs("LastModify")
    address = objRs("Alamat")
    ...
    objRs.Close
    Set objRs = Nothing
   
End Function

here the question is i want pass the "SD", "Sekolah" and "BJC0000" into the function the error occurs.

Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/index.asp, line 15, column 36
user.displayData("SD","Sekolah","BJC0000")
-----------------------------------^
0
Comment
Question by:MaxTo
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Expert Comment

by:chops123
ID: 7145587
Apart from the function call,your instance creation syntax is also incorrect

Try this

Dim retVal
set user = Server.CreateObject("survey.dbConnect")
retVal = user.displayData("SD","Sekolah","BJC0000")    

'When you call a function,a value will be returned and therefore you need to collect that value and when creating an instance of an active-x component on the server,you need to use server.createobject

Regards
KC

0
 
LVL 3

Expert Comment

by:sanjaykattimani
ID: 7146025
alternately you can call the function like this, when you dont want the out put of the function.

user.displayData "SD","Sekolah","BJC0000"
0
 
LVL 2

Expert Comment

by:chops123
ID: 7146070
In that case you need not have a function,it would do with a subroutine

KC
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:MaxTo
ID: 7147947
To KC :

from your comment, i change it like this

<%
 set user
 Dim retVal
 set user = Server.CreateObject("survey.dbConnect")
 retVal = user.displayData("SD", "Sekolah", "JBC0000")
%>

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.
/index.asp, line 13 ( set user = Server.CreateObject("survey.dbConnect")
)
0
 
LVL 2

Expert Comment

by:chops123
ID: 7148295
Have you registered your DLL file on the server ? This error is usually encountered when the Active-X DLL is not registered.

do this: Assuming the path of your dll is in C:\winnt\system32. Click start->Run

regsvr32 c:\winnt\system32\myDLL.dll

KC
0
 
LVL 15

Accepted Solution

by:
robbert earned 50 total points
ID: 7150082
> Public Function displayData(Optional db As String, Optional tb As String, Optional userName As String)

If you don't state "ByVal", explicitely:

Public Function displayData(Optional ByVal db As String, Optional ByVal tb As String, Optional ByVal userName As String)

any parameters are assumed to be ByRef (that's the default). - Using ByRef, the data type must match, and the only data type VBScript/ASP knows is Variant.

Use ByVal, or, if you're passing parameters back by using ByRef, declare "As Variant":

Public Function displayData(Optional ByRef db As Variant, Optional ByRef tb As Variant, Optional ByRef userName As Variant)

-- Definitely, and try to grade "A" if this helped you. Thanks.
0
 

Author Comment

by:MaxTo
ID: 7153324
sorry friends thanks for everybody help. This problem i had solved. so i will close this question if got chance next time i will give you people the mark and good grade.
0
 
LVL 15

Expert Comment

by:robbert
ID: 7568583
Next time a good grade? - Hope you'll be able to explain some reasoning then, or even post any comment (for clarification).

This current situation with this question is unsatisfactory.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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