April 29, 2009 at 11:13 am
Hi,
I am pretty new to asp.net programming, and I am running into some major problems.
I built a web form to accept basic information: Soc Sec, First Name, Last Name, etc.
From a book "Beginning ASP.net 3.5 in C# 2008" by Mathew Macdonald, I wrote some C# code to connect to a table I built in Sql 2005.
I have set up a drop down list to display the name of the patients in the table I built.
It is empty.
When I go to add a new patient, I get the error: "Error inserting record. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Before I run the program I test the connection, and it passes.
"test connection succeeded"
When I go into my configurtation file and change the Integratted Security from SSPI to false, I get a different error.
The user is not associated with a trusted SQL Server connection.
Any suggestions?
Thanks
Paul
April 29, 2009 at 2:33 pm
By the sounds of it, it is might be your connection string. Do you want the Form to connect as the user or as the web service under its own credentils?
if you want to use a connection string similar to the one below. The Authentication mode of the SQL server should be set to mixed mode as you will be using SQL authentication. This means all conection that uses this string will connect under these credentials.
connectionString="Data Source=ServerName;Initial Catalog=Database;User ID=UserName;Password=password" providerName="System.Data.SqlClient"
If you use Integrated Authentication, you need to setup IIS to use windows Authentication and untick anonymous access (Otherwise it will try and use Network Service account or the account iis run under to connect). You might need to change Web.config to include something like this under the authentication section.
[identity impersonate="true"/]
[authentication mode="Windows"/]
Hope this helps:-D
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply