Sunday, March 11, 2012

Bad day with .net

Hi

I am new to ASP.net and trying to connecting with SQL Server in Visual Studio by following instruction are given in below url page.

http://www.codeproject.com/aspnet/SQLConnect.asp?

I have done all steps upto where below code is shown in page

*********************************************************

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
SqlConnection1.Open()
If SqlConnection1.State = ConnectionState.Open Then
Label4.Text = "SQL Connection is open"
Else
Label4.Text = "SQL Connection is closed"
End If
End Sub

******************************************************

But I am getting error !

Server Error in '/WebService1' Application.

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

Source Error:

Line 126: 'Put user code to initialize the page hereLine 127:Line 128:SqlConnection1.Open()Line 129:If SqlConnection1.State = ConnectionState.Open ThenLine 130: Label1.Text = "SQL Connection is open"


Source File:c:\inetpub\wwwroot\WebService1\SqlConnect.aspx.vb Line:128

Stack Trace:

[SqlException: Login failed for user 'COMP3\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474 System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372 System.Data.SqlClient.SqlConnection.Open() +384 WebService1.SqlConnect.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebService1\SqlConnect.aspx.vb:128 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

Note : All steps are finely executed by me !

One thing more As one instruction in Help Page that "right click theSQLConnection1 object to study its properties."

But i am not able to see the properties of it becoz properties tag is disable in right click and i am strange with this experience in Visual Studio that i am not able to edit the code in Editor area ( Where Below code in seen)

Private Sub Page_Load(ByVal sender As System.Object, _ByVal e As .EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

End Sub

So I am totally confused or unable to find out the problem that in my Visual Studio Or Connectivity?

PLEASE HELP ME TO RESOLVE this issue!!Confused [*-)]

Check your connection string and see if you are providing the correct credentials to access the database.|||

Connection String is automatically generated by Visual Studio.Net aftter dragging table 'employee' from server explorer

So I think it not changeable.

Suggest me other way to connecting with database

|||

See "SQL Server" in this document:How To: Use the Network Service Account to Access Resources in ASP.NET.

In your case, though, you are using the ASPNET account, not NETWORK SERVICE, but all the same steps still apply.

The connection string is still configurable, though.

No comments:

Post a Comment