1

Hi,

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.

flag

60% accept rate
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. – Canavar Jul 10 '09 at 23:42

2 Answers

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>
link|flag
Thanks, you were right, it worked great. – flavour404 Jul 10 '09 at 23:24
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>

?

link|flag
You were correct, the concatenation '+' wasn't needed. – flavour404 Jul 10 '09 at 23:23

Your Answer

Get an OpenID
or
never shown

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