connecting Sqlserver2000 with ASP.net(C#)
-
hi all; I am trying to connect sql server2000 with asp.net(C#). but nothing happens. Actual problem comming from connection string which is not coming to solve my code is as follow: <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Page language="C#" %> void Page_Load() { string my="workstation id=HOME;packet size=4096;integrated security=SSPI;data source=HOME;persist security info=False;initial catalog=PrintQuota"; SqlConnection mycon=new SqlConnection(my); try { mycon.Open(); TextBox1.Text="Connection opend successfully"; mycon.Close(); } catch (Exception g) { TextBox1.Text=g.ToString(); } } The main problem is with user id and password,, i have also checked with integrated security=SSPI but no way to connect..the same string i use in window application but its work but here in web app its not working error message from exception is error System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at ASP.UserInfo_aspx.Page_Load() in http://localhost/WebApplication1/UserInfo.aspx:line 16 plz solve my problem . i m waiting for replies. with regards Ishtiaq
-
hi all; I am trying to connect sql server2000 with asp.net(C#). but nothing happens. Actual problem comming from connection string which is not coming to solve my code is as follow: <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Page language="C#" %> void Page_Load() { string my="workstation id=HOME;packet size=4096;integrated security=SSPI;data source=HOME;persist security info=False;initial catalog=PrintQuota"; SqlConnection mycon=new SqlConnection(my); try { mycon.Open(); TextBox1.Text="Connection opend successfully"; mycon.Close(); } catch (Exception g) { TextBox1.Text=g.ToString(); } } The main problem is with user id and password,, i have also checked with integrated security=SSPI but no way to connect..the same string i use in window application but its work but here in web app its not working error message from exception is error System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at ASP.UserInfo_aspx.Page_Load() in http://localhost/WebApplication1/UserInfo.aspx:line 16 plz solve my problem . i m waiting for replies. with regards Ishtiaq
Hi there, make bold this line:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
. Here you see the user is not which you expect. It is because your WebApplication is executed by the wrong user. You should use the "impersonate" mechanism (in the we.config) to make the application run with your user. Depending on which Operative System you are using, it can be also accomplished by changing the user with wich runs ASP.NET process or the ApplicationPool (IIS 6, win2003). Another way is to make the application impersonate the user which causes the session to init. These all are configuration issues you can find in Microsoft MSDN and TecNet, and more places all abroad Internet. Hope this help, Parsiphal -
Hi there, make bold this line:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
. Here you see the user is not which you expect. It is because your WebApplication is executed by the wrong user. You should use the "impersonate" mechanism (in the we.config) to make the application run with your user. Depending on which Operative System you are using, it can be also accomplished by changing the user with wich runs ASP.NET process or the ApplicationPool (IIS 6, win2003). Another way is to make the application impersonate the user which causes the session to init. These all are configuration issues you can find in Microsoft MSDN and TecNet, and more places all abroad Internet. Hope this help, Parsiphalwell sir i got yours point ..i am using windows 2003 server as operating system..wat i have to do to connect the database (sql server200) in asp.net. plz tell me the steps that which code of lines should be written where???or wat i do with theuser etc plz help me in some way. With best wishes Ishtiaq Ahmed