Question

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.

Was it helpful?

Solution

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>

OTHER TIPS

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>

?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top