Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

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:SqlDataSource>

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?
Avatar of deepu chandran
deepu chandran
Flag of Germany image

ASKER CERTIFIED SOLUTION
Avatar of hawks4ever
hawks4ever
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial