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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp fun type mismatch help!

Status
Not open for further replies.

atdawgie

Technical User
Sep 29, 2001
60
US
Hi,

I have program below that works fine if I hard code the values in question but if I try to use variables I get a type mismatch.

If the line reads
Call FirstCOM.CreateUser("MyComputer","myaccount")
it works fine as long as the "MyComputer" is an actual computer.

But if I create a form, type in the two values above, call this asp file in a form action=thisfile.asp I get a type mismatch on the line above. I printout the variables in question to make sure they contain values and they do.

This call doesn't work where comp_name and usr_account are variables
Call FirstCOM.CreateUser(comp_name,usr_account)

Code below:
<html>
<body>
<head><title>testing</title></head>
<% language = vbscript %>
<%dim comp_name
dim usr_account
dim FirstCOM
comp_name = request.form("computername")
usr_account = request.form("account")
response.write(comp_name)
%>

<P>computer: <%= comp_name %>
<P>account: <%= usr_account %>


<%Set FirstCOM = Server.CreateObject("ADSI_COM.UsrMgmt")
Call FirstCOM.CreateUser(comp_name,usr_account) '*****TYPE MISMATCH HERE
Response.write "Error " & Err.number & "<BR>"
Response.write "Done!"
%>
</body>
</html>

 
If your COM object is expecting a string, then you probably should set it as a string value before passing it. For example:
Code:
comp_name = CStr(request.form("computername"))
usr_account = CStr(request.form("account")) 'or if this needs to be an integer then set it accordingly
...
Call FirstCOM.CreateUser(comp_name,usr_account)

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
Thanks, oddly enough it worked but only if I put the converted the usr_account string at this line
Call FirstCOM.CreateUser(cStr(comp_name),cStr(usr_account))

instead of this line
usr_account = CStr(request.form("account"))

but it didn't matter when I converted the comp_name string, either line/way worked. Why do you think that is?
 
I cannot imagine a reason off the top of my head why it would have failed for the account. What type of data is usually stored in that field? I can say that typically when you are passing a value back to a function (particularly a VB function), unless it is typed as a variant, you need to pass it back from ASP specifically as it is required in the function.

Otherwise, glad that it worked.

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top