【发布时间】:2016-11-11 13:27:15
【问题描述】:
ASP.NET 2.0 框架
当用户访问该页面时,我正在尝试列出所有与用户相关的条目。我在会话中为访客设置了会话变量。现在我想用那个 ID 查询数据库。它似乎正在执行,但没有返回任何结果(我在单独的代码部分中显示内容)。
请帮忙!
<asp:SqlDataSource
ID="UserReports"
runat="server"
ConnectionString= "<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand = "SELECT [ID], [ReportName], [ReportPath] FROM [Pan].
[dbo].[Reports] WHERE ([VisitorID] = @VisitorID)"
OnSelecting = "SqldsExample_Selecting">
<SelectParameters>
<asp:Parameter Name="VisitorID" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
On the code behind:
Sub SqldsExample_Selecting(sender As Object, e As
SqlDataSourceSelectingEventArgs)
UserReports.SelectParameters.Add("@VisitorID", Session("VisitorID"))
End Sub
【问题讨论】:
-
我正在寻找 VB,而不是 C#。
-
您可以在以下帖子中查看 marc_s 的答案:stackoverflow.com/questions/17000390/…。
标签: asp.net session sqldatasource selectcommand