Sea*_*dge 0 c# asp.net web-config
我的web.config文件是这样的:
<appSettings>
...
<add key="gvConnString" value="user id = user1; password= pwww333; server= magcian; database= OnB; connection timeout=30" />
...
</appSettings>
Run Code Online (Sandbox Code Playgroud)
在我的.aspx页面中,我使用它如下:
<asp:SqlDataSource ID="dsPopulateDepartment" runat="server" ConnectionString="<%$ ConnectionStrings:gvConnString %>" SelectCommand="SELECT * FROM HERECOMES"></asp:SqlDataSource>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Exception Details: System.InvalidOperationException: The connection name 'gvConnString' was not found in the applications configuration or the connection string is empty.
您将连接字符串放在<appSettings>元素中.它需要在<connectionStrings>元素中 - 它们是不同的.
<connectionStrings>
<add name="gvConnString" connectionString="..."/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)