1

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
4

1 に答える 1

2

使用しないでください。セッション変数に直接アクセスするため<asp:Parameter>に使用する必要があります。<asp:SessionParameter>

<SelectParameters>
    <asp:SessionParameter Name="VisitorID" SessionField="VisitorID" />
</SelectParameters> 
于 2016-07-09T09:55:23.540 に答える