I'm trying to access some data from SQL Server in ASP.NET, but I can't get a parameter to pass to a SQL Server stored procedure. The parameter is located in the URL (i.e. www.company.com/ImportantManager.aspx?id=Jones,%Bob
), as I only want Bob Jones' results displayed.
NiceMgr_Total
is the stored procedure. I have seen many different responses to similar questions on here and the Microsoft forums, but I think the stored procedure might be messing it up (the @manager
parameter specifically - the other parameters seem to work fine).
I've tried it multiple ways, and I'm getting an assortment of parser errors and "parameter not found" errors. Thanks for your help.
Here's the code:
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource7" runat="server"
AutoGenerateRows="False" EmptyDataText="There are no data records to display."
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Manager" HeaderText="Manager" SortExpression="Manager"
ItemStyle-Width="41px" ItemStyle-HorizontalAlign="Center"
HeaderStyle-CssClass="tableheader3" ItemStyle-CssClass="tabledata2" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource7" runat="server"
ConnectionString="<%$ConnectionStrings:ConnectionString3 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>"
SelectCommand="DECLARE @PerDate VARCHAR(50)
DECLARE @CurrentDate DATETIME
SET @CurrentDate = (SELECT MAX([MostRecent]) FROM sameDB.dbo.RecentDate)
SET @PerDate = CAST(CONVERT(VARCHAR(10),@CurrentDate,120) AS VARCHAR(50))
EXEC [NiceMgr_Total] @date1=@PerDate, @date2=@PerDate, @manager=@MgrName">
<selectparameters>
<asp:querystringparameter name="MgrName" DBtype="String"
QueryStringField="<%Response.Write(Request.QueryString.Item("id"))%>" />
</selectparameters>
</asp:SqlDataSource>