Click to See Complete Forum and Search --> : How to connect to Database in SQL Server 2000


tungdt
August 29th, 2004, 02:46 AM
Hi everyone,

I am using Windows XP, Microsoft SQL Server 200 and Visual Studio.NET.
When I connect to Database in Microsoft SQL 200 in ASP.NET ( inside Visual Basic.NET )...I encountered an error as listed below:

My server name is: DB.

Thanks for your help.
Looking forward to hearing any comments.


Me.SqlConnection1.ConnectionString = "workstation id=DB;packet size=4096;integrated security=SSPI;data source=" & _
"DB;persist security info=False;initial catalog=Northwind"


SqlConnection1.Open()
SqlDataAdapter1.SelectCommand.ExecuteNonQuery()
SqlDataAdapter1.Fill(DataSet1)


---------------------------------------------------------------
Server Error in '/VB/WebApplication3' Application.
--------------------------------------------------------------------------------

Login failed for user 'DB\ASPNET'.
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 'DB\ASPNET'.

Source Error:


Line 155: 'Put user code to initialize the page here
Line 156:
Line 157: SqlConnection1.Open()
Line 158: SqlDataAdapter1.SelectCommand.ExecuteNonQuery()
Line 159: SqlDataAdapter1.Fill(DataSet1)


Source File: F:\Visual Studio.net\ASP.NET\WebApplication3\WebForm1.aspx.vb Line: 157

Stack Trace:


[SqlException: Login failed for user 'DB\ASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
WebApplication3.WebForm1.Page_Load(Object sender, EventArgs e) in F:\Visual Studio.net\ASP.NET\WebApplication3\WebForm1.aspx.vb:157
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731




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

MRutledge
August 30th, 2004, 09:31 AM
When using SSPI authentication (integrated security) your application is trying to log on to the database with the ASP.NET worker process. You have to give the ASP.NET user access to your database.

franky_25
September 2nd, 2004, 02:38 PM
You application would need a login id to access data....
Try ther following

Me.SqlConnection1.ConnectionString = "workstation id=DB;packet size=4096;integrated security=SSPI;data source=" & _
"DB;persist security info=False;initial catalog=Northwind;uid=sa;pwd="
lemme know if it works,
Frank

tungdt
September 3rd, 2004, 09:25 PM
Thank all of you for your suggestions....

A couple of weeks ago I fixed this problem already...


Thanks.