How to pass variables to select statement

How to pass variables to select statement

Post by crasho200 » Sat, 12 Jul 2003 22:35:03



I have following statement in my stored procedure.  From first two rows I
can see the values for variables.










 
 
 

How to pass variables to select statement

Post by Karl Ritte » Mon, 14 Jul 2003 17:52:14






4> go
(1 row affected)

 -----------
          52

(1 row affected)
1>


> I have following statement in my stored procedure.  From first two rows I
> can see the values for variables.


like










 
 
 

1. Trouble passing variable in SELECT statement in Stored Procedure

I am passing a variable value to a stored procedure to SQL Server 7.0
via an ASP page on IIS 5.0. The code on the ASP page is as follows:
<%
Function DoSomething(strVar)
SQL = "sp_Foo '" & strVar & "'"
set rs = dBConnection.DBQuery(SQL)
     while not rs.EOF
       Response.write("<OPTION value=""" & trim(rs("item")) & """> " &
trim(rs("item")) & "</OPTION>")
     rs.MoveNext
     Wend
End Function
%>
<SELECT id=select3 name=variable1>
<OPTION selected value="">Any</OPTION>
<%
'***********************************************
'Pass the variablefield as the argument to the
'DoSomething funtion
'***********************************************
DoSomething("variable1")
%>
</SELECT>
<SELECT id=select3 name=variableN>
<OPTION selected value="">Any</OPTION>
<%
'***********************************************
'Pass the variablefield as the argument to the
'DoSomething funtion
'***********************************************
DoSomething("variableN")
%>
</SELECT>

The Stored Procedure looks like:
CREATE PROCEDURE sp_Foo

AS

NOT NULL

The record set only returns the strVar value in the drop down menu that
is created in the ASP page. When I place the variable directly in
stored procedure, it runs fine.

How can I code the stored procedure so that it will accept the
variable? What am I doing wrong? Any help would be appreciated.

Thanks

Sent via Deja.com
http://www.deja.com/

2. Sybase Developers $$$

3. Can you pass a where with multiple statements without a variable for each where statement

4. question

5. Set a variable to equal a select statement containing variables

6. ISR for swedish

7. select statement using :variable as selected item

8. Datagrids, Unbound Forms & ADO

9. Build SQL Statement in Stored Procedure by Passing Variables

10. Case Statement and variables passed to stored procedures

11. Passing a variable to a SQL statement from Visual J++

12. How to pass a variable to a SET statement

13. How to pass a variable into a SQL Statement Command is Data Environment