Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 Article Discussion
 Article: Writing dyanmic SQL in an ASP page

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-07-29 : 16:21:08
Alejandro writes "Please help me, I can't write the syntax for something like this: search?cat1=America&cat2=EEUU . . . "

Article Link.

dasiefker
Starting Member

2 Posts

Posted - 2001-12-04 : 10:01:26
You could also put this code in a stored procedure and pass the values as parameters. This gives you added security (not transmitting your sql code), and if the sql statement were very long, it also gives added performance.

T-SQL code to create stored procedure
--------------------------------------------------
create proc usp_MiTable
@cat1 varchar(100) = 'default',
@cat2 varchar(100) = 'default' as

SELECT * FROM MiTable
Where cat1 = @cat1
and cat2 = @cat2

go
--------------------------------------------------

VB to execute stored procedure (assuming you're
using ADO, and you have a recordset and connection
object declared already)
--------------------------------------------------
MySQL = "exec usp_MiTable " & _
"'" & Request.QueryString("cat1") & "', " & _
"'" & Request.QueryString("cat2") & "'"
call objRS.open(mysql,objconn)
--------------------------------------------------


Dave <><
Go to Top of Page
   

- Advertisement -