1

My question is in regard to the SelectComman in the

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:conStr %>" 
             SelectCommand="SELECT * " +
                            "FROM myTable">
        </asp:SqlDataSource>

Obviously I have given an example but why won't it let me spread the sql statement over a couple of lines?

Thanks, R.

1
  • Hi flavour404, it would be nice to upvote for the people who answered your question correct. Just click the up arrow near the answer. And click check sign near the answer to select accepted answer. These are encourages people to answer questions. Commented Jul 10, 2009 at 23:42

2 Answers 2

2

If you want to write your query in multiple lines write it without the concatenation like that :

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
     ConnectionString="<%$ ConnectionStrings:conStr %>" 
     SelectCommand="SELECT * 
                   FROM myTable">
</asp:SqlDataSource>
Sign up to request clarification or add additional context in comments.

Comments

0

Because you are assigning the value to an attribute of an element in markup. You can certainly do this in the code behind by setting the property, but without spacing instead of code-like concatenation this can't work.

Have you tried:

<asp:SqlDataSource ID="SqlDataSource2" runat="server"
    ConnectionString="<%$ ConnectionStrings:conStr %>"
    SelectCommand=
      "SELECT * 
       FROM myTable
       ...Where...">
</asp:SqlDataSource>

?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.