Error in using util.get_settings method

Posted by Sudhak under ASP.NET on 11/5/2009 | Views : 2286 | Status : [Member] | Replies : 1
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




Responses

Posted by: Vuyiswamb on: 11/16/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Try to add this in your web config


<system.web>
<identity impersonate="true" userName="myusername" password="ooops" />
<.system.web>


Thank you for posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Sudhak, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response