hery

hery

  • NA
  • 7
  • 0

How to embed variable value in sqldatasource session parameter in c#

Feb 22 2011 2:13 PM
I want to question how to embed variable value in sqldatasource session parameter in c#. This is mycode:

default.aspx:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
  ConnectionString="<%$ ConnectionStrings:Ora2011 %>"
  ProviderName="<%$ ConnectionStrings:Ora2011.ProviderName %>"
  SelectCommand="SELECT ID, CATEGORY_NAME FROM (:INVENT_CATEGORY)">
  <SelectParameters>
  <asp:SessionParameter Name="INVENT_CATEGORY" SessionField="INVENT_CATEGORY" Type="String" />
  </SelectParameters> 
</asp:SqlDataSource>



C#:

protected void Page_Load(object sender, EventArgs e)
{
  string table = "V_INVENTORY"
  Session["INVENT_CATEGORY"] = table;
}


When i run this program, i get error "invalid table name". Why i can't embed variable into sqldatasource from session parameter. Thanks for your help



Anyone help me in my problem. Thanks

Answers (1)