简体   繁体   中英

SelectCommand with web.config key variable

Looking to select records from my DB in ASP.NET using <SelectCommand> with a var from the web.config.

Can't seem to find the proper syntax to work.

no code behind file or vb code in page, so trying to do in just asp.net page.

SelectCommand="SELECT * FROM ClassesTbl WHERE AppName = <%= ConfigurationManager.AppSettings('AppName') %>" 

actually found a way to make it work:

added:

<SelectParameters>
    <asp:Parameter Name="getAppName" DefaultValue="<%$ AppSettings:AppName %>"/>
</SelectParameters>

and changed SelectCommand to:

SelectCommand="SELECT * FROM ClassesTbl WHERE AppName = @getAppName"  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM