Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Error on accessing Data

Author  Topic 

babak
Starting Member

1 Post

Posted - 2007-02-11 : 04:14:27
Hi,
I've created an "ASP.NET Web Application" project in Visual Studio and I want to simply open a connection to a database in SQL Server. All I have done is adding these 3 lines below without modifying any
other generated codes by Visual Studio.(I've done this within code behind in Page_Load() not by <script> tag within
HTML code)

public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlConnection c = new SqlConnection();
c.ConnectionString = "workstation id=BABAK;integrated security=SSPI;initial catalog=db1;persist security info=False";
c.Open();
}
...
}


But I get this error :

Server Error in '/projects/fortest/tDB2' Application.
----------------------------------------------------------------

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

Source Error:


Line 24: SqlConnection c = new SqlConnection();
Line 25: c.ConnectionString = "workstation id=BABAK;integrated security=SSPI;initial catalog=db1;persist security info=False";
Line 26: c.Open();
Line 27: }
Line 28:

Source File: c:\inetpub\wwwroot\projects\fortest\tdb2\webform1.aspx.cs Line: 26


What's wrong ?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-11 : 11:50:20
See if this helps you:
[url]http://www.connectionstrings.com/?carrier=sqlserver[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -