YZlat
asked on
How to specify connection string from web.config inside the SqlDataSource
I have a connection string specified in my web.config file
<add name="conn" connectionString="my string here" />
and here is my SqlDataSource:
<asp:SqlDataSource ID="sds1" runat="server" ConnectionString ="<%$ ConnectionStrings:conn" %>" SelectCommand="SELECT Field1 FROM Table1"></asp:SqlDataSourc e>
I keep getting 2 errors:
1)The server tag is not well formed
and
2)Literal expressions like '<%$ ConnectionStrings:conn" %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ ConnectionStrings:conn"%>" /> instead.
What am I doing wrong?
<add name="conn" connectionString="my string here" />
and here is my SqlDataSource:
<asp:SqlDataSource ID="sds1" runat="server" ConnectionString ="<%$ ConnectionStrings:conn" %>" SelectCommand="SELECT Field1 FROM Table1"></asp:SqlDataSourc
I keep getting 2 errors:
1)The server tag is not well formed
and
2)Literal expressions like '<%$ ConnectionStrings:conn" %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ ConnectionStrings:conn"%>"
What am I doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please refer this msdn link,
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.connectionstring.aspx
Regards
Deepu