0

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') %>" 
2
  • What error do you get? Commented Sep 3, 2016 at 21:28
  • not a valid SQL statement - need to add as a parameter I think? Commented Sep 3, 2016 at 21:29

1 Answer 1

1

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"  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.