468,277 Members | 1,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,277 developers. It's quick & easy.

trusted sql server connection problem!?

I an trying to connect to a sql server in asp.net with the sql connection
object, and every time i try to open the connection i get this
Server Error in '/' Application.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

why am i getting this? and how do i get around it? I am logged into the
domain on the machine that the asp.net system is on, the sql server is a
seperate machine... vs.net can do a preview of the data and read it in
vs.net ide, and i can connect and retrieve data using the server explorer,
but when i do it programaticly it gives me that error... here is my
connection sub...
Private dbconnectionstring As String = "workstation id=DELL5100;packet
size=4096;integrated security=SSPI;data source=BENE-SQL;persist security
info=False;initial catalog=ReschIntranet"
Public dbconnection As New SqlClient.SqlConnection(dbconnectionstring)
Nov 17 '05 #1
4 1766
confirm what account the web app is using to log into sql server. Its been
a while since I did any asp.net, but I recall this being an issue then and
we had to make sure the 'asp.net user' could log into sql server...or
something along those lines.
"Brian Henry" <br******@adelphia.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
I an trying to connect to a sql server in asp.net with the sql connection
object, and every time i try to open the connection i get this
Server Error in '/' Application.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

why am i getting this? and how do i get around it? I am logged into the
domain on the machine that the asp.net system is on, the sql server is a
seperate machine... vs.net can do a preview of the data and read it in
vs.net ide, and i can connect and retrieve data using the server explorer,
but when i do it programaticly it gives me that error... here is my
connection sub...
Private dbconnectionstring As String = "workstation id=DELL5100;packet
size=4096;integrated security=SSPI;data source=BENE-SQL;persist security
info=False;initial catalog=ReschIntranet"
Public dbconnection As New SqlClient.SqlConnection(dbconnectionstring)

Nov 17 '05 #2
This is because during development, it is using your integrated security
authentication to connect to the database.

At run time, ASPNET is what's trying to connect, and it is not associated
with a trusted connection.

So you can either set up ASPNET as a user with rights, or just use a
username/password account and pass that in to sql server when trying to
connect.

"Brian Henry" <br******@adelphia.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
I an trying to connect to a sql server in asp.net with the sql connection
object, and every time i try to open the connection i get this
Server Error in '/' Application.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

why am i getting this? and how do i get around it? I am logged into the
domain on the machine that the asp.net system is on, the sql server is a
seperate machine... vs.net can do a preview of the data and read it in
vs.net ide, and i can connect and retrieve data using the server explorer,
but when i do it programaticly it gives me that error... here is my
connection sub...
Private dbconnectionstring As String = "workstation id=DELL5100;packet
size=4096;integrated security=SSPI;data source=BENE-SQL;persist security
info=False;initial catalog=ReschIntranet"
Public dbconnection As New SqlClient.SqlConnection(dbconnectionstring)

Nov 17 '05 #3
or what we do here, is switch the web site to run on itegrated security
(assuming working locally), then it will pass your credentials. also, you
will need to set the identity impersonate=true in the web.config.

jim
"Brian Henry" <br******@adelphia.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
I an trying to connect to a sql server in asp.net with the sql connection
object, and every time i try to open the connection i get this
Server Error in '/' Application.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

why am i getting this? and how do i get around it? I am logged into the
domain on the machine that the asp.net system is on, the sql server is a
seperate machine... vs.net can do a preview of the data and read it in
vs.net ide, and i can connect and retrieve data using the server explorer,
but when i do it programaticly it gives me that error... here is my
connection sub...
Private dbconnectionstring As String = "workstation id=DELL5100;packet
size=4096;integrated security=SSPI;data source=BENE-SQL;persist security
info=False;initial catalog=ReschIntranet"
Public dbconnection As New SqlClient.SqlConnection(dbconnectionstring)

Nov 17 '05 #4
As you are using integrated security, you will want to do one of the
following:

1. Assign the IUSR account rights to the database (bad idea, but easy)
2. Change to mixed mode security (better, and still quite easy)
3. Create a user account to access the SQL Server and have the data routines
assume that identity when calling the database (programming heavy)
4. Restrict the web app to accounts that have permission to use SQL Server
in your domain (will not work for Internet apps)

The IDE runs under your account, the web app runs under IUSR unless you
restrict it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Brian Henry" <br******@adelphia.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
I an trying to connect to a sql server in asp.net with the sql connection
object, and every time i try to open the connection i get this
Server Error in '/' Application.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

why am i getting this? and how do i get around it? I am logged into the
domain on the machine that the asp.net system is on, the sql server is a
seperate machine... vs.net can do a preview of the data and read it in
vs.net ide, and i can connect and retrieve data using the server explorer,
but when i do it programaticly it gives me that error... here is my
connection sub...
Private dbconnectionstring As String = "workstation id=DELL5100;packet
size=4096;integrated security=SSPI;data source=BENE-SQL;persist security
info=False;initial catalog=ReschIntranet"
Public dbconnection As New SqlClient.SqlConnection(dbconnectionstring)

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Brian Henry | last post: by
7 posts views Thread by Ray Valenti | last post: by
3 posts views Thread by Mad Scientist Jr | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
1 post views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.