Hi,
I have web.config file in which there is a key value and when trying to access it in code file using util.get_setting, I am getting an error
This is the code
public static SqlConnection get_sqlconnection()
{
string connection_string = Util.get_setting("ConnectionString", "MISSING CONNECTION STRING");
SqlConnection conn = new SqlConnection(connection_string);
conn.Open();
return conn;
}
web.config key
<add key="ConnectionString" value="server=servername;database=btt;Trusted_Connection=TRUE"/>
ERROR While trying to access the site
Server Error in '/btt' Application.
--------------------------------------------------------------------------------
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Source Error:
Line 189: string connection_string = Util.get_setting("ConnectionString", "MISSING CONNECTION STRING");
Line 190: SqlConnection conn = new SqlConnection(connection_string);
Line 191: conn.Open();
Line 192: return conn;
Line 193: }
Source File: c:\Inetpub\wwwroot\wss\VirtualDirectories\btnet\www\App_Code\dbutil.cs Line: 191
Stack Trace:
Can you please help me out?
Regards,
Sudha