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 have a SqlDataSource that I am trying to set an insert command with additional text after every table to switch for testing. I wanted to do this with an <appSetting> in the web.config.

When I do the following

<asp:SqlDataSource ID="SqlDataSourceDRDocument" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ISNORTHConnectionString %>" 
    ProviderName="System.Data.SqlClient"          
    InsertCommand="insert into DR_Document<%$ AppSettings:tablename %>
    (Columns) Values (Values)">
<asp:SqlDataSource>

I get

Invalid object name 'DR_Division<%$ AppSettings:tablename %>'

What am I doing wrong?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

In Page_Load()

string tablename = DocumentRepository.Settings.getSetting("tablename");
SqlDataSourceDRDocument.InsertCommand="insert into DR_Document"+
tablename+" (Columns) Values (Values)";

In web.config

<appSettings>
  <add key="tablename" value="_test"></add>
</appSettings>
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.