Not associated with a trusted SQL Server connection

  • Thread starter Thread starter DMS
  • Start date Start date
D

DMS

I am new to ASP & ADO.NET and IIS web applications, but
not to SQL databases. I can successfully build Windows-
forms apps using Visual Studio ADO. However, I can't
connect for Web forms. I created a sqlconnection and
sqladapter to my SQL Server,Northwind db, which I dragged
from Server Explorer. I generate a dataset, and Preview
Data in the da, works fine. I then enter vb code on
Page_Load event:
SqlDataAdapter1.Fill(ds)
DataGrid1.DataSource = ds.Tables("Employees")
DataGrid1.DataBind()
When I build and browse (localhost), I get:
Server Error in 'myapp'...SqlException: Login failed for
user (null). Reason: Not associated with a trusted SQL
Server connection. I have since found error codes
SQLState 42000 and SQL Error 18452, which could be
permissions among other things, but haven't found anything
detailed on how to fix this. The
server mode is Windows auth. I've tried various settings
in Web.config connection string, tried configuring IIS
Virtual Directory Managment setting Integrated Security
and I downloaded the .NET framework onto SQL server. I
still get the error.
Perhaps my workstation version of IIS is not configured
properly(?); do I need an IIS-server edition? I would
appreciate any help or reference to articles concerning
this problem (IIS config - VisStudio.NET - SQL
connectivity).
 
DMS:

I'm not positive, but I was under the impression that you can't use Windows
Authentication with an ASP.NET application. I think you need to switch it
to SQL Server and Windows Authentication, add the respective user account
and the corresponding permissions, and use that account(s) in your
connection string.

HTH,

Bill
 
Sure you can. When you use Integrated Security=SSPI with an IIS/ASP
application, the system logs you in using the ASPNET account which must be
granted permission to access the database resources.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Bill:

I currently have my DB set using mixed mode authentication but that's only
b/c I was under the mistaken impression that I couldn't used SSPI for web
access. I guess from a security POV, I should adjust the code to use the
IIS/ASP account and move back to Windows Authentication to minimize risk?
(Not to mention it'd be easier to manage).

Thanks again,

Bill
 
MS recommends SSPI and hits this point any number of times in the
whitepapers I've read. Yes, I would follow their advice here.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Then, the ASPNET account must be a Domain account, with
what privileges? and what password? I added a local
ASPNET account to SQL server, but it didn't work.
 
Back
Top