473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Connecting to a sql server database


I have a client who is trying to connect to a sql server database using
asp.net and this is the error message that they get, any ideas on what is
causing the error message and what the correction for this.

Code they are using

<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<body>

<%
Dim Conn As SqlConnection = New SqlConnection()
Conn.ConnectionString = "Provider=SQLOLEDB;Data Source=blah;Initial
Catalog=blah;user id=blah;password=blah2;"
Conn.Open()
Dim cmdSelectSpecies as SqlCommand
Dim species_result as SqlDataReader

cmdSelectSpecies = New SqlCommand("SELECT SpeciesName FROM Species",Conn)
species_result = cmdSelectSpecies.ExecuteReader()
While species_result.Read()
Response.Write( "<li>" )
Response.Write( species_result( "SpeciesName" ) )
end While
species_result.close()
Conn.close()
%>
</body>
</html>
Error MEssage
Server Error in '/' 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 11: "Initial Catalog=hekman_contract;" & _
Line 12: "Integrated Security=SSPI"
Line 13: Conn.Open()
Line 14:
Line 15:
Source File: c:\inetpub\wwwroot\hekman_contract\test.AW.aspx Line: 13

Stack Trace:
[SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
+474
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection
(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.test_AW_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in c:\inetpub\wwwroot\hekman_contract\test.AW.aspx:13
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1926


----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032

--
J.Daly
structure:interactive
Ph: 616-364-7423
Fx: 616-364-6941

http://www.structureinteractive.com

Jul 21 '05 #1
2 1932
You are trying to use integrated security in your app (as is shown in the
line numbered code where the connection string is shown). This looks like
it's running on 2003 server, because asp.net runs under 'network service' by
default in this case. The 'network service' account doesn't have access to
sql server, hence integrated security fails.

The page source code you show is using a username/password to connect, but
clearly your client modifed the connection string to use integrated
security.

Don't write your code as asp.net script, since then your clients will start
modifying it in unpredictable ways, and you will have a support nightmare on
your hands. You should give them specific instructions on setting up a
username/password on their sql server and have them put this in web.config
or someplace like that, and have your app look there for connection
information. I also noticed you are using the old ASP method of writing out
all the HTML on your page - this is pretty antiquated. I would recommend you
take advantage of all the asp.net server controls now available to do this
sort of thing.
"Irishmaninusa"
<jd***@structuctureinteractive.com.takemeoffifyouw antoemailme> wrote in
message news:%2****************@TK2MSFTNGP15.phx.gbl...

I have a client who is trying to connect to a sql server database using
asp.net and this is the error message that they get, any ideas on what is
causing the error message and what the correction for this.

Code they are using

<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<body>

<%
Dim Conn As SqlConnection = New SqlConnection()
Conn.ConnectionString = "Provider=SQLOLEDB;Data Source=blah;Initial
Catalog=blah;user id=blah;password=blah2;"
Conn.Open()
Dim cmdSelectSpecies as SqlCommand
Dim species_result as SqlDataReader

cmdSelectSpecies = New SqlCommand("SELECT SpeciesName FROM Species",Conn)
species_result = cmdSelectSpecies.ExecuteReader()
While species_result.Read()
Response.Write( "<li>" )
Response.Write( species_result( "SpeciesName" ) )
end While
species_result.close()
Conn.close()
%>
</body>
</html>
Error MEssage
Server Error in '/' 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 11: "Initial Catalog=hekman_contract;" & _ Line 12: "Integrated Security=SSPI"
Line 13: Conn.Open()
Line 14:
Line 15:
Source File: c:\inetpub\wwwroot\hekman_contract\test.AW.aspx Line: 13

Stack Trace:
[SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
+474
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection
(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.test_AW_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in c:\inetpub\wwwroot\hekman_contract\test.AW.aspx:13
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1926


-------------------------------------------------------------------------- -- ----
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

--
J.Daly
structure:interactive
Ph: 616-364-7423
Fx: 616-364-6941

http://www.structureinteractive.com

Jul 21 '05 #2
Thanks.
"Marina" <so*****@nospam.com> wrote in message
news:Oh**************@TK2MSFTNGP14.phx.gbl...
You are trying to use integrated security in your app (as is shown in the
line numbered code where the connection string is shown). This looks like
it's running on 2003 server, because asp.net runs under 'network service' by default in this case. The 'network service' account doesn't have access to sql server, hence integrated security fails.

The page source code you show is using a username/password to connect, but
clearly your client modifed the connection string to use integrated
security.

Don't write your code as asp.net script, since then your clients will start modifying it in unpredictable ways, and you will have a support nightmare on your hands. You should give them specific instructions on setting up a
username/password on their sql server and have them put this in web.config
or someplace like that, and have your app look there for connection
information. I also noticed you are using the old ASP method of writing out all the HTML on your page - this is pretty antiquated. I would recommend you take advantage of all the asp.net server controls now available to do this
sort of thing.
"Irishmaninusa"
<jd***@structuctureinteractive.com.takemeoffifyouw antoemailme> wrote in
message news:%2****************@TK2MSFTNGP15.phx.gbl...

I have a client who is trying to connect to a sql server database using
asp.net and this is the error message that they get, any ideas on what is causing the error message and what the correction for this.

Code they are using

<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<body>

<%
Dim Conn As SqlConnection = New SqlConnection()
Conn.ConnectionString = "Provider=SQLOLEDB;Data Source=blah;Initial
Catalog=blah;user id=blah;password=blah2;"
Conn.Open()
Dim cmdSelectSpecies as SqlCommand
Dim species_result as SqlDataReader

cmdSelectSpecies = New SqlCommand("SELECT SpeciesName FROM Species",Conn) species_result = cmdSelectSpecies.ExecuteReader()
While species_result.Read()
Response.Write( "<li>" )
Response.Write( species_result( "SpeciesName" ) )
end While
species_result.close()
Conn.close()
%>
</body>
</html>
Error MEssage
Server Error in '/' 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 11: "Initial Catalog=hekman_contract;" & _
Line 12: "Integrated Security=SSPI"
Line 13: Conn.Open()
Line 14:
Line 15:
Source File: c:\inetpub\wwwroot\hekman_contract\test.AW.aspx Line: 13

Stack Trace:
[SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
+474
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection
(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.test_AW_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in

c:\inetpub\wwwroot\hekman_contract\test.AW.aspx:13 System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1926


--------------------------------------------------------------------------
--
----
Version Information: Microsoft .NET Framework Version:1.1.4322.2032;

ASP.NET
Version:1.1.4322.2032

--
J.Daly
structure:interactive
Ph: 616-364-7423
Fx: 616-364-6941

http://www.structureinteractive.com


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
14
by: John Spiegel | last post by:
Hi all, I'm missing something, probably stupid, on connecting to a SQL Server database from an aspx file. I haven't really done much w/ SQL Server and suspect that it's a problem on that side. ...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
2
by: Patrick F | last post by:
Hi, i have SQL Server 2005 and a database set that is called, myCompany the problem is that i cant connect from my page to it, here is from the web.config: ( i have got this connectionstring from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.