Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm getting SqlDatasource table from query string likes

<asp:SqlDataSource ID="myDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
    SelectCommand="SELECT * FROM @DynamicTable D  WHERE D.ID = @QueryId ">
   <SelectParameters>
      <asp:QueryStringParameter Name="DynamicTable" QueryStringField="TableName" Type="String" />
      <asp:QueryStringParameter Name="QueryId" QueryStringField="ID" Type="String" />
   </SelectParameters>
</asp:SqlDataSource>

But It's show me this error ,

Must declare the table variable "@DynamicTable"

How can I fix it ?

share|improve this question
2  
This can't be done. You can't have your tablename as parameter in your query. Tablename must be static. Look at this post, might help ... though it has been done in code and not in design.stackoverflow.com/questions/14003241/… –  Rahul Jul 6 '13 at 4:52
    
The SelectCommand is just an example , my real SelectCommand long about 3 lines and I've to bind almost 10 tables dynamically , Rahul :( . Your link is useful for me but by this way , I'll have too many coding . Is there any different way ? Thanks Rahul :) –  zey Jul 6 '13 at 5:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.