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
 General SQL Server Forums
 New to SQL Server Programming
 passing quertystring parameter to stored proc

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-12-04 : 11:01:00
How do I do that with this stored procedure?

@weekdat datetime


As
SET NOCOUNT ON


DECLARE @listCol VARCHAR(2000)

SELECT @listCol = STUFF(( SELECT DISTINCT

'],[' + convert(varchar(10),(Weekdat),1) --converting the weekdat

FROM test

where weekdat = @weekdat + Request.Querystring("dte")



Here's the info to pass into the querystring:

Dim selectedItems(ListBox1.Items.Count - 1) As Integer
Dim numSelectedItems As Integer = 0

For i As Integer = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Selected Then
selectedItems(numSelectedItems) = i
numSelectedItems += 1
End If
Next

Dim queryString As String = ""

If RadioBtnReg.Checked AndAlso RadioBtnWeek.Checked Then
queryString = "test1.aspx?period=m"

For i As Integer = 0 To numSelectedItems - 1
queryString &= "&dte" & (i + 1).ToString() & "=" & ListBox1.Items(selectedItems(i)).Value
Next
End If


Here's the querystring that's passed:

http://localhost:3640/stuff/test1.aspx?period=m&dte1=11/20/2009&dte2=11/13/2009&dte3=11/06/2009

I need to pass dte2, dte3 etc.

weipublic
Starting Member

19 Posts

Posted - 2009-12-05 : 21:51:50
Add another parameter to the stored procedure, this parameter will accepts the querystring value.
When you invoke the stored procedure, just pass the querystring value to this parameter.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-12-07 : 09:55:53
Thanks that worked I didn't even think about that.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-12-07 : 12:15:03
but maybe beware.....

http://xkcd.com/327/


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -