Forum Moderators: open

Message Too Old, No Replies

using stored procedure

stored procedure

         

justify

3:15 pm on Jul 26, 2003 (gmt 0)

10+ Year Member



Hi, EverBody I use SQL SERVER 2000 DB, i create a procedure like a below code. I want to send "user_id" variable which i create the procedure and want to get a value how can i do this My codes are here
Thanks in advance

CREATE procedure users
@USER_ID int
As

Select * from WEB_USERS where USER_ID= @user_id
GO
----
My asp codes
This is a 1.asp page this ok.
<%
Set rs = Server.CreateObject("ADODB.Recordset")
SQL = " SELECT * FROM WEB_USERS "
rs.open SQL,Con

While not rs.eof
%>
<a href="2.asp?kul_id=<%= rs("USER_ID") %>"><%= rs("USER_ID") %>&nbsp;<%= RS("USERNAME") %></a><br>
<%
rs.MoveNext
Wend
%>
This is 2.asp page, i dont know exactly what i do, i think parameter is wrong and bad.
mistake is where it is written "kul_id"

<%
kul_id = request.querystring("kul_id")

set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = Con
cmd.CommandText = "users"
cmd.CommandType = 4
cmd.CommandTimeout = 0
cmd.Prepared = true
cmd.Parameters.Append cmd.CreateParameter &_
("@user_id",adVarChar,adParamInput ,10,"kul_id")

cmd.Parameters.Append cmd.CreateParameter &_
("@user_id",adInteger,adParamOutput)
Set rs = cmd.Execute
%>

<%=intNumber = cmd.Parameters ("@user_id") %>

gangstah

12:34 pm on Jul 27, 2003 (gmt 0)

10+ Year Member



Hi,

It looks like your problem may be the way your passing kul_id into the stored proc.

When setting kul_id you should type it as an integer (ex. kul_id = CInt(Request.QueryString("kul_id")) )

And then when you pass it into the stored proc, don't pass it in as a text string (i.e. "kul_id") because SQL will think your trying to send in the text "kul_id" when it's expecting an integer. Instead just pass in the variable you created earlier from the query string:

cmd.Parameters.Append cmd.CreateParameter &_
("@user_id",adVarChar,adParamInput ,10,kul_id)

Instead of

cmd.Parameters.Append cmd.CreateParameter &_
("@user_id",adVarChar,adParamInput ,10,"kul_id")

ALSO

In your last line of code, don't refer to the command object for @userid's value. The stored proc is only reading this as an INPUT variable, NOT output. You should refer to the recordset object that you created in the line before and check for the value of user_id (assuming that's the name of a field in your table).

Hope that helps.

gangstah

12:35 pm on Jul 27, 2003 (gmt 0)

10+ Year Member



Oh, and welcome to Webmaster World!