Friday, February 24, 2012

C# web app connection to SQL 2000

Hello, everyone,
I am trying to connect to a SQL server db with a C# app and when I debug I
get:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
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
'(null)'. Reason: Not associated with a trusted SQL Server connection.
Source Error:
Line 27: if (!Page.IsPostBack)
Line 28: {
Line 29: sqlDataAdapter1.Fill(dsStudents1);
Line 30: DataGrid1.DataBind();
Line 31: }
Can somebody give me any suggestions?
Thanks,
AntonioYou are probably using the key word Integrated Security=SSPI or
trusted_connection=yes in your connection string and your Windows credential
(i.e. that of the login that runs the program) has not been granted access t
o
the SQL Server instance.
I'd first change Integrated Security=SSPI to user=myUser;pwd=myPassword, and
verify that there is no problem with connectivity itself (and there shouldn'
t
be any per your error message). Then, grant the Windows login access to the
SQL Server instance, and now you can use Integrated Security=SSPI.
Linchi
"Antonio" wrote:

> Hello, everyone,
> I am trying to connect to a SQL server db with a C# app and when I debug I
> get:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> 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 us
er
> '(null)'. Reason: Not associated with a trusted SQL Server connection.
> Source Error:
>
> Line 27: if (!Page.IsPostBack)
> Line 28: {
> Line 29: sqlDataAdapter1.Fill(dsStudents1);
> Line 30: DataGrid1.DataBind();
> Line 31: }
>
> Can somebody give me any suggestions?
> Thanks,
>
> Antonio
>
>|||You need to grant access to ASPNET user to your database. That is the
account that web application use.
"Antonio" <info@.awfulcards.com> wrote in message
news:uMqrFT2SGHA.5884@.TK2MSFTNGP14.phx.gbl...
> Hello, everyone,
> I am trying to connect to a SQL server db with a C# app and when I debug I
> get:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> 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 '(null)'. Reason: Not associated with a trusted SQL Server
> connection.
> Source Error:
>
> Line 27: if (!Page.IsPostBack)
> Line 28: {
> Line 29: sqlDataAdapter1.Fill(dsStudents1);
> Line 30: DataGrid1.DataBind();
> Line 31: }
>
> Can somebody give me any suggestions?
> Thanks,
>
> Antonio
>|||The ASPNET user is setup in the database (the ASPNET user in the server, not
my machine) with access to the specific database, as owner.
"Shimon Sim" wrote:

> You need to grant access to ASPNET user to your database. That is the
> account that web application use.
> "Antonio" <info@.awfulcards.com> wrote in message
> news:uMqrFT2SGHA.5884@.TK2MSFTNGP14.phx.gbl...
>
>|||What is your connection string?
It is strange that user is '(null)'.
"Antonio" <Antonio@.discussions.microsoft.com> wrote in message
news:35ADEC88-2C2A-45AB-BFD9-C86607839493@.microsoft.com...[vbcol=seagreen]
> The ASPNET user is setup in the database (the ASPNET user in the server,
> not
> my machine) with access to the specific database, as owner.
> "Shimon Sim" wrote:
>|||Didi you grant the appropiate rights to the service account which
starts the worker process (on *your* computer) on the SQL Server ?
Domain\ServiceAccount (Your Computer) -- > has to be prviledged on the
SQL Server
Make sure that you didn=B4t accept anonymous authentication on your
webserver.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--

No comments:

Post a Comment