the usual way for me to do sqldatasource is this. Which just normally shows all forums in a table format.
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:elibraryDBConnectionString %>" SelectCommand="SELECT [forum_id], [forum_topic], [forum_description], [forum_status], [company_name], [replies_count], [publish_date], [publisher_name], [forum_img_link], [moderator_name] FROM [forum_accept_tbl]"></asp:SqlDataSource>
However, I want to show not all forum, but only one forum with session forum id that I've got. Below is the code that didn't work for me.
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:elibraryDBConnectionString %>" SelectCommand="SELECT [forum_id], [forum_topic], [forum_description], [forum_status], [company_name], [replies_count], [publish_date], [publisher_name], [forum_img_link], [moderator_name] FROM [forum_accept_tbl] WHERE [Forum_id] = Session["Forum_id"]"></asp:SqlDataSource>
I tried to add WHERE but it didn't recognize the session. This is on my forum.aspx code btw. Should it be changed in forum.aspx.cs or not that necessary? I'm still new to asp.net and I think this is a simple mistake but I hope I can learn more.
Aucun commentaire:
Enregistrer un commentaire