Click here to Skip to main content
16,021,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one stored procedure which takes an one input parameter and returns the result. i tried lots of solutions but it not worked. it is throwing an internal server error (HTTP 500 Internal Server Error)and the page is blank
(The website cannot display the page). Could you please help me to sort out this problem.

What I have tried:

VB
Dim strSQLConnection
dim strPass2
strSQLConnection = "driver={SQL Server};server=[servername];database=[DB name];uid=;pwd=;"
Set Conn = Server.CreateObject("ADODB.Connection")
Set objCommand = Server.CreateObject("ADODB.Command")
Set objParam = Server.CreateObject("ADODB.Parameter")
Set rstUsers = Server.CreateObject("ADODB.Recordset")
Conn.Open strSQLConnection

objCommand.ActiveConnection = strSQLConnection
objCommand.commandtext = "Getdetails" 
objCommand.CommandType = 4   'defines cmd type as stored proc
Set objParm = objCommand.CreateParameter("@UserId", 3,1,,strUserId)          
objCommand.Parameters.Append objParm

set rstUsers = objCommand.Execute

If Not rstUsers.EOF Then
	strPass2 = rstUsers("ntuserid")
      
End if
Posted
Updated 8-Jun-17 5:07am
v3
Comments
Richard Deeming 8-Jun-17 11:09am    
Assuming strUserId is actually an integer, that code looks OK as far as I can see. But it has been 15+ years since I last touched ADODB!
Append and CreateParameter Methods Example (VB)[^]

You're going to need to add a custom error page, and log the error details somewhere.
How To Create a Custom ASP Error Handling Page[^]
Creating Custom ASP Error Pages[^]

1 solution

Leo, your parameter object is called objParam, but you using objParm in your Set and Append statements.
 
Share this answer
 
Comments
Dave Kreskowiak 6-Aug-24 16:25pm    
Look at the date on the question. You're seven years too late.
Richard Deeming 13-Aug-24 4:19am    
Not only far too late, but also inaccurate. Without specifying Option Explicit, VBScript doesn't care if you use a variable without declaring it first.

The Set objParm = ... line will create a new parameter and assign it to a new variable. The .Append objParm line will append that new parameter object to the command's parameters. The objParam variable will not be used anywhere.

Whilst it's always a good idea to use Option Explicit to pick up simple typos like this, the typo was clearly not the cause of the OP's problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900