Showing posts with label local. Show all posts
Showing posts with label local. Show all posts

Friday, March 30, 2012

Login failed for user NT AUTHORITY\NETWORK SERVICE.

I've tried to use Windows authentication to connect to database in MS SQL Server 2000, my connection string like below:
"server=(local);Initial Catalog=myDatabase;Trusted_Connection=yes"
when I run my code, there is an error occur with below message:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
My SQL Server is configured as Window authentication.
I can't resolve this problem.
Please whow me how to do!
Thank you very much!
You either need to grant the Network Service account access rights toSQL Server, or your application needs to impersonate a specific Windowsuser that has rights to the database.

Login failed for user NT AUTHORITY\LOCAL SERVICE

I just installed the Issue Tracker using .net 1.1 (on my computer). When I try to log in via the login page, I get:

Login failed for user 'NT AUTHORITY\LOCAL SERVICE'

Here is my stack trace info:

SqlException: Login failed for user 'NT AUTHORITY\LOCAL SERVICE'.]
System.Data.SqlClient.ConnectionPool.CreateConnection() +402
System.Data.SqlClient.ConnectionPool.UserCreateRequest() +151
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +386
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASPNET.StarterKit.IssueTracker.DataAccessLayer.SQLDataAccessLayer.ExecuteScalarCmd(SqlCommand sqlCmd) +129
ASPNET.StarterKit.IssueTracker.DataAccessLayer.SQLDataAccessLayer.Authenticate(String username, String password) +184
ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.ITUser.Authenticate(String username, String password) +44
ASPNET.StarterKit.IssueTracker.DesktopDefault.Login(Object s, EventArgs e) +84
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

I have added everyone, asp.net, local service, network service - all full control on the entire folder. Restarted IIS - still can't log in. Please help.

Hi, look at the exception you'll find it is from SQL. So you have to add proper permissions in SQL for the account rather than give control on the folder. Please open SQL Server Management Studio (Enterprise Manager) and go to the SQL instance which you're trying to connect, and explore Security->Logins->right click choose 'New Login'-> choose Windows Authentication and type the Windows account name. Remember to give sufficient permissions to the new added login.|||Thanks for the info. That fixed my issue.|||

What exactly should those permissions be, Read-only, owner, read/write.. what?

Thanks

|||

thelane:

What exactly should those permissions be, Read-only, owner, read/write.. what?

Thanks

The permissions I mean here is permissions in SQL, such as SELECT/INSERT/UPDATE on tables, CREATE DATABASES, EXECUTE stored procedures, and so onSmile You can take a look at this link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_security_94dv.asp

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

Hello all -

I'm trying to connect to a Sql Server 2005 database from my local development machine, which is running IIS 5.1 (Windows XP Pro). The web application is not using impersonation and has anonymous access enabled. In my system's machine.config file, I've set the processModel section to look like:

<processModel userName="System" password="AutoGenerate" />

This has been working fine for us connecting to SQL Server 2000 databases (running on Windows 2003). When we connect, I access Sql 2000 databases under the context of "OurDomain\MyMachineName$". However, we've recently installed Sql Server 2005 on a new Windows 2003 server & when I connect to that server, I receive the error:

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

when trying to call the SqlConnection.Open() method. Our connection string is very basic:

Data Source=sql-dev2; Initial Catalog=TestDatabase; Integrated Security=True; Application Name=PrototypeWebservice;

In the Sql Server logins, we've granted the computer account "OurDomain\MyMachineName$" db_owner access to every database (in both Sql Server 2000 & 2005).

I am able to connect to the Sql Server 2005 databases if I change my section in machine.config to <processModel userName="OurDomina\myPersonalAccount" password="myPersonalPwd"/>, or if I move the application to an IIS6 server & set the application pool identity to NETWORK SERVICE, but we'd like to continue accessing our Sql Server 2005 databases (from our development machines running IIS5.1) as we currently access our Sql Server 2000 databases; under the context of "OurDomain\MyMachineName$".

Would anyone have any ideas why this would be happening or how to resolve? Thanks in advance.

Please check this blog: http://blogs.msdn.com/sql_protocols/archive/2006/12/02/understanding-kerberos-and-ntlm-authentication-in-sql-server-connections.aspx

.....

[1] "Login Failed for user 'NT Authority\ANONYMOUS' LOGON"

In this scenario, client make tcp connection, and it is most likely running under LocalSystem account, and there is no SPN registered for SQL instance, hence, NTLM is used, however, LocalSystem account inherits from System Context instead of a true user-based context, thus, failed as 'ANONYMOUS LOGON'. See http://support.microsoft.com/kb/132679.

The workaround here is

a. ask your domain administrator to manually register SPN if your SQL Server running under a domain user account.

b. use NP connection.

c. change your sql server to run under either localsystem account or networkservice account.

|||

That was the ticket!!! Thank you very much.

For future reference, the problem we ran into was that we had multiple active directory accounts registered with the same SPN. One entry was registered under the computer account sql server was running on & the other was the user account the sql server service was running under. We detected this by looking into the System event log on the domains PDC (the entry was EventID 11, Source KDC. Exact steps we followed were those suggested by other users on the thread: http://www.eventid.net/display.asp?eventid=11&eventno=569&source=KDC&phase=1). After removing the entry for the computer account, kerberos authentication succeeded.

Thanks again!

|||Thanks for the feedback.

Wednesday, March 28, 2012

Login failed for user . The user is not associated with a trusted SQL Server connection.

I have a windows 2003 server hosting MS SQL Server 2005. Another windows 2003 server hosting my App, and clients from the local intranet and outside (web). How do I surpass this problem, when it all works fine locally on my development machine?

Use Forms authentication!

Al

|||

I am using Forms authentication.

<

connectionStrings>

<

addname="memSocConnection"connectionString=" Data Source=WSPASQL01; Initial Catalog=mem_soc;Integrated Security=True"providerName="System.Data.SqlClient" />

<

addname="MySqlRoleManagerConnection"connectionString="Data Source=WSPASQL01;Initial Catalog=mem_soc_core;Integrated Security=True"providerName="System.Data.SqlClient" />

<

addname="MySqlMembershipProviderConnection"connectionString="Data Source=WSPASQL01;Initial Catalog=mem_soc_core;Integrated Security=True"providerName="System.Data.SqlClient" />

</

connectionStrings>

<authentication mode="Forms"><formsname="SqlAuthCookie" loginUrl="admin/login.aspx" timeout="10" /> </authentication>

This works fine locally. I am trying to migrate the application onto the servers. As soon as I use the WSPASQL01 server it fails. I have followed the walkthrough from microsoft on using forms authentication and still no progress. I have assigned roles to the login 'aspnet'.

Wednesday, March 21, 2012

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

Hello all -

I'm trying to connect to a Sql Server 2005 database from my local development machine, which is running IIS 5.1 (Windows XP Pro). The web application is not using impersonation and has anonymous access enabled. In my system's machine.config file, I've set the processModel section to look like:

<processModel userName="System" password="AutoGenerate" />

This has been working fine for us connecting to SQL Server 2000 databases (running on Windows 2003). When we connect, I access Sql 2000 databases under the context of "OurDomain\MyMachineName$". However, we've recently installed Sql Server 2005 on a new Windows 2003 server & when I connect to that server, I receive the error:

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

when trying to call the SqlConnection.Open() method. Our connection string is very basic:

Data Source=sql-dev2; Initial Catalog=TestDatabase; Integrated Security=True; Application Name=PrototypeWebservice;

In the Sql Server logins, we've granted the computer account "OurDomain\MyMachineName$" db_owner access to every database (in both Sql Server 2000 & 2005).

I am able to connect to the Sql Server 2005 databases if I change my section in machine.config to <processModel userName="OurDomina\myPersonalAccount" password="myPersonalPwd"/>, or if I move the application to an IIS6 server & set the application pool identity to NETWORK SERVICE, but we'd like to continue accessing our Sql Server 2005 databases (from our development machines running IIS5.1) as we currently access our Sql Server 2000 databases; under the context of "OurDomain\MyMachineName$".

Would anyone have any ideas why this would be happening or how to resolve? Thanks in advance.

Please check this blog: http://blogs.msdn.com/sql_protocols/archive/2006/12/02/understanding-kerberos-and-ntlm-authentication-in-sql-server-connections.aspx

.....

[1] "Login Failed for user 'NT Authority\ANONYMOUS' LOGON"

In this scenario, client make tcp connection, and it is most likely running under LocalSystem account, and there is no SPN registered for SQL instance, hence, NTLM is used, however, LocalSystem account inherits from System Context instead of a true user-based context, thus, failed as 'ANONYMOUS LOGON'. See http://support.microsoft.com/kb/132679.

The workaround here is

a. ask your domain administrator to manually register SPN if your SQL Server running under a domain user account.

b. use NP connection.

c. change your sql server to run under either localsystem account or networkservice account.

|||

That was the ticket!!! Thank you very much.

For future reference, the problem we ran into was that we had multiple active directory accounts registered with the same SPN. One entry was registered under the computer account sql server was running on & the other was the user account the sql server service was running under. We detected this by looking into the System event log on the domains PDC (the entry was EventID 11, Source KDC. Exact steps we followed were those suggested by other users on the thread: http://www.eventid.net/display.asp?eventid=11&eventno=569&source=KDC&phase=1). After removing the entry for the computer account, kerberos authentication succeeded.

Thanks again!

|||Thanks for the feedback.

Login failed for user

I published my web pages using Visual Studio 2005 to a local IIS server, the local machine has a proxie, when I published the pages on my personal laptop with a practice database on a SQL server it runs find, but when I put it on the machine with the actual running database on SQL Server 2005 I get the following error, can any please let me know what I can do to fix this problem.

Server Error in '/BPAlarmQuery' Application.

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

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): Login failed for user 'ODOWIN911\ASPNET'.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734787 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 System.Data.SqlClient.SqlConnection.Open() +111 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770 System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +92 System.Web.UI.WebControls.ListControl.PerformSelect() +31 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26 System.Web.UI.Control.PreRenderRecursiveInternal() +77 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360

Thank you in advance.

Try the suggestions on this page:

http://msdn2.microsoft.com/en-us/library/ab4e6cky.aspx

Login failed for user

Application works fine when run on local computer, but when accessed from another computer or after moving to hosted server, I get the 'Login failed for user SERVERNAME\iusr_servername' error. The application is attempting to access SQL Server 2000 database with hard coded user name and password. I've read about how to do this and it works fine locally, but I don't see what I am missing. Help!See the steps I listed inthis post to solve your problem.
|||Thanks for your response. This helps a bit, but not completly. After adding the IUSR account and granting access to the database, I was able to connect properly from my test computer to my developement computer that is running the app and the SQL Server after removing all authenticated access in IIS. Unfortunately, I don't have that degree of access on the hosted SQL Server. I thought that the connection string was used to gain access to the SQL Server, and don't understand why the IUSR account needs to have access as well.|||

It is because I bet you in your connection string, you are using trusted connections. On the production box, what you will have to do is either ask your hoster to grant access to that database. The best secure way is to create a whole new windows user account for you and set the IIS application to run under your user. That user is also given grant access to that database.

However, the likelihood of that happening sounds low. Why don't you specify a SQL user name and password (without the trusted connection)?

|||Thank you! I knew that the answer had to be something simple that I was missing. Nothing like being a rooky. Removing the Trusted Connection did the trick.

Login failed for user

I have been following the WebMatrix guided tour for the End to End application for VB.net. Everything went very smooth on my local box, but when I transferred the code to our dev server and made it into an Application through IIS, it fails after I enter in a bogus username and password. Below is my debug info. CORP is our domain and USHOUVMET01D is the machine name.

Can someone point me in the right direction on how to fix this?

------------------------

Login failed for user 'CORP\USHOUVMET01D$'.
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 'CORP\USHOUVMET01D$'.

Source Error:

Line 41: dataAdapter.SelectCommand = dbCommand
Line 42: Dim dataSet As System.Data.DataSet = New System.Data.DataSet
Line 43: dataAdapter.Fill(dataSet)
Line 44:
Line 45: Return dataSet

Source File: D:\InetPub\Wwwroot\jason\EndToEndVB\login.aspx Line: 43

Stack Trace:

[SqlException: Login failed for user 'CORP\USHOUVMET01D$'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ASP.Login_aspx.GetUser(String userName, String userPassword) in D:\InetPub\Wwwroot\jason\EndToEndVB\login.aspx:43
ASP.Login_aspx.LoginBtn_Click(Object Sender, EventArgs E) in D:\InetPub\Wwwroot\jason\EndToEndVB\login.aspx:8
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032bump!|||What happens when you enter a valid username and password?

What type of authentication are you using? (forms/windows)

How are you connecting to SQL? Looks like a trusted connection. Your error looks like a delegation issue (web server is not trusted for delegation).

Are you using WIN2K or 2003?

(note: I'm not familiar with the tutorial)|||Thank you for your response!

To answer your questions:
Same thing happens for valid username/pass.
Forms.
I do have a trusted connection. Should I take that out?
2003 for web server, 2000 for db server.|||
You have a few choices:

1) run the web application pool as a domain user with database access

2) run the web application pool as a local user and create an identical user (same username and password) on the database server with database access

3) use SQL Authentication and specify the username and password in the connection string

Each alternative has it's own advantages and disadvantages in terms of security and setup effort.

The first option is relatively secure from a database access perspective since the username and password are not stored in the connection string, but it runs the web application as a domain user. An attacker who comprimises the security of your application may be able to gain access to network resources. Also, you would need permissions to add a domain user to your current domain.

The second option keeps the username and password out of your connection string and runs the application as a local user, so an attacker would not be able to gain access to network resources. I'm not sure if it is possible when the database server and web server are running different versions of Windows (haven't tried it personally).

The third option seems to be the most popular, especially in hosted internet solutions, although it is the least secure. The security of the third option can be enhanced by encrypting the username and password, or the whole connection string for that matter, and decrypting it at runtime. The third option is the easiest to setup.

Ultimately the choice is yours. Let me know if you still need help after you've decided which route to take. If you are doing this for learning purposes, it might be a good idea to try each one.

|||That all makes sense now! I used Option 3, since I'll most likely be developing internal applications. We also have our own version of database security that was custom built.

Anyway, thanks for all your help on this. I'm sure this is the first of many more posts to come!

Login Failed for SQL Server db

I recently formatted my pc, everything is set but one thing, the sql server db.

I can't remember how I set the permission for my local machine for the db.

Error: Login Faile for <machineName>\ASPNET

How do I add the user to access the db?

Thanks all,

Zaththe ASPNET is a local account that you need to assign to some role in SQL server.
Create a new Logon in SQL server for that account and give that Login the appropriate DB permissions.

Do NOT make that account a member of your local Administrators group. youd never run a live server that way so dont do it with a dev server either.|||In Enterprise Manager, I added ASPNET for one of the roles.

Still login failed.

I added the new role to the db_owner, still failed.

I went to security folder, added ASPNET there as well in Logins, still no luck.

The conn string I am using is...

<add key="ConnectString" value="Data Source=localhost; Initial Catalog=dbName; User ID=ASPNET; Password=*********; Trusted_Connection=True;"
No wonder I like to stick to coding... LOL

Suggestions?

Thanks,

Zath|||When trusted_connection=true, the userid and password are not required as the user credentials are derived from the machine logon.

i.e the machines ASPNET account.

your connection string includes a userid and password which might be getting evaluated as SQL credentials even though your specifying to use a trusted_connection. (your mixing your security options)

adding the ASPNET machine account to a role is not the same as creating a SQL login with the name ASPNET.

try removinguser id andpassword from your connection string
or
try creating an actual SQL Login and turning off Trusted_Connection|||Try this url http://whoozoo.co.uk/winxpFilePerms.htm use it to configure file permissions
in Windows XP and then give Asp.net account read and write permissions for the application folder before setting up the SQL Server Permissions for same account with DBO permissions in the Database created for the application. Hope this helps.

Kind regards,
Gift Peddie|||I tried both ways and still no luck.

With just the id and password, I get this error...
Login failed for user 'ASPNET'. Reason: Not associated with a trusted SQL Server connection

And with the Trusted_Connection and no id or pw, just the login failed.

Ironically, I work in IIS Admin and am familiar with permissions, but this db thing has me stumped... LOL

I even tried to create a new test db but with the same results.

Any more suggestions will be helpful,

Thanks again,

Zath|||SUCCESS!!!!!

I knew I would get it, I always do... It's a curse I tell ya, a curse... LOL

In SQL Server Enterprise Manager, under the db in question, go to Security Folder, then logins (which I did before)

Create the the new user, in this case I created ASPNET.

But, don't use SQL Server Authentication, but use Windows Authentication.

Input the new user, then choose from the drop down list your local machine name.

I did however create the ASPNET user in the wwwroot folder permissions, don't know if this was required first, most likely... but I'm in.....

And don't know why the userid and pw didn't work, but doesn't matter now....

Used this conn string...

----
<add key="ConnectString" value="Data Source=localhost; Initial Catalog=dbName; Integrated Security=SSPI; PWD=Trusted_Connection=True;"
---
I'm sure when I'm ready to transfer to "production" server and change the conn string, it will work fine because it does in my main app!

Thanks for the help everyone!

Zathsql

Monday, March 19, 2012

Login failed for give user id

I tried to create a mining model from a remote SQL 2000 database using local user id of remote server. Whenver I try to process the model I am getting login failed error. But the same model runs fine when I configure datasource using windows credentials.I found out the reason, when I set the impersonation mode to service account/degfault its working. But when I set to specific user name and password, its not working. Can somebody suggest me the possible cause.|||I found answer myself. I just created a local user and a role in analysis service database mapping to local user and granted him appropriate rights. Now I can process the data model under "impersonate particular user mode"

Login failed for ".

What am I missing? Computer A is windows xp sp2 with visual studio 2005. Computer B is Server2003 with SQLServer2005.

Computer A: local website directory security configured for anonymous access using a local user computer_A\username and password. The password is NOT managed by iIIS.

Computer B: SQLServer2005 allows local and remote connections, sql server and windows authentication. Local user computer_B\username and password is defined.

User computer_B\username is defined in the sql server security logins with login properties allowing access to database mydb. The default scheama db_owner. The database (mydb) properties/permissions/effective permissions are Authenticate, connect, delete,execute,insert,select and update.

The webconfig file has a connection string defined as:Name=LocalSqlServer Connection String=Data Source=server.domain-name,1433;Initial Catalog=mydb;Integrated Security=True;. The webconfig file contains <remove name="LocalSqlServer" and then an <add name="LocalSqlServer" with the above information. The webconfig file also has <identity impersonate="true" /> and <authentication mode="Forms">
<forms name=".ASPXFORMSAUTH" loginUrl="login.aspx" protection="Validation"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>

My login page manually reads a table called usrTbl via a stored proceedure to check for the existance of the username and password presented.(Yes I know it is in the clear-bad bad me, just bear with me for the problem). It then formsredirectfromlogin to the original requested page whice is Default.aspx.

Default.aspx has a gridview defined. The datasource is defined in the page load event as:

gridview1.datasource = membership.getallusers()

gridview1.databind()

I get an error Login failed for ". User not associated with a trusted connection

How can that be, the database has been access earlier with the same connection string. I checked to make sure user computer_B\username can log on to computer B.

Please help me to understand a solution to this

You may hit the same issue discussed in the following thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=285649&SiteID=1

Thanks
Laurentiu

|||

Not the same thing. I know my post was long, but i needed to provide the complete environment.

Failure is with different tables in the same database. I guess I failde to say the membership tables were created in the same database. Bottom Line Here.

Read database table fine, redirect to different page, failure reading same database.

WHY

|||

Pasting answer from usenet forum:

Hi Bill,

Welcome to use MSDN Managed Newsgroup Support.

From your description, my understanding is that, you can not config a web
application to connect to the remote SQL Server instance. If I
misunderstood your concern, please feel free to point it out.

Please use the following entry for the <identity> in web.config.

<identity impersonate="true" userName="computer_b\username"
password="password" />

Since you impersonated in your web application but you did not give a
credential to the application, so that, it will use the IIS account to
connect to the SQL Server. Of cause this will cause the login error.

Hope this will be helpful.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Login failed - Error Number: 18456 - Severity: 14 - State: 1

Hi.
After re-installing Windows Vista on my PC, I can no longer log on to my
local SQL Server 2005 (SP2) (even though my account name is the same for
Vista). I can not even connect with a new query, so I can not update user
information or anything like that. It gives me this error:
Login failed for user 'Thomas-PC\Thomas'. (.Net SqlClient Data Provider)
--
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
--
Server Name: thomas-pc
Error Number: 18456
Severity: 14
State: 1
Line Number: 65536
--
Program Location:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
enlistOK)
at
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
host, String newPassword, Boolean redirectedUserInstance, SqlConnection
owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at
Microsoft.SqlServer.Management.UI.ConnectionDlg.NewRegisteredServerForm.testConnection_Click(Object sender, EventArgs e)
Unfortunately the link provided above for more help takes me to a page that
does not exist.
I did try to uninstall the SQL Server 2005 and re-install it again but
without any difference.
I can connect to servers on other servers, but as I mentioned not my local
SQL server.
Thanks for your advise/help,
ThomasCan you connect if you launch SSMS with "run as Administrator"? If so, add
your Windows login to the sysadmin role so that you don't need to run with
elevated privileges , except when managing services.
Hope this helps.
Dan Guzman
SQL Server MVP
"Thomas Vang" <Thomas Vang@.discussions.microsoft.com> wrote in message
news:6DD3607B-2A9B-4C69-BBBD-61ADA479D211@.microsoft.com...
> Hi.
> After re-installing Windows Vista on my PC, I can no longer log on to my
> local SQL Server 2005 (SP2) (even though my account name is the same for
> Vista). I can not even connect with a new query, so I can not update user
> information or anything like that. It gives me this error:
> Login failed for user 'Thomas-PC\Thomas'. (.Net SqlClient Data Provider)
> --
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
> --
> Server Name: thomas-pc
> Error Number: 18456
> Severity: 14
> State: 1
> Line Number: 65536
> --
> Program Location:
> at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> exception, Boolean breakConnection)
> at
> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> stateObj)
> at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> bulkCopyHandler, TdsParserStateObject stateObj)
> at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> enlistOK)
> at
> System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> timerExpire, SqlConnection owningObject)
> at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
> at
> System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> owningObject, SqlConnectionString connectionOptions, String newPassword,
> Boolean redirectedUserInstance)
> at
> System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> identity, SqlConnectionString connectionOptions, Object providerInfo,
> String
> newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
> at
> System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> owningConnection)
> at
> System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
> owningConnection, DbConnectionPoolGroup poolGroup)
> at
> System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> owningConnection)
> at
> System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> outerConnection, DbConnectionFactory connectionFactory)
> at System.Data.SqlClient.SqlConnection.Open()
> at
> Microsoft.SqlServer.Management.UI.ConnectionDlg.NewRegisteredServerForm.testConnection_Click(Object
> sender, EventArgs e)
> Unfortunately the link provided above for more help takes me to a page
> that
> does not exist.
> I did try to uninstall the SQL Server 2005 and re-install it again but
> without any difference.
> I can connect to servers on other servers, but as I mentioned not my local
> SQL server.
> Thanks for your advise/help,
> Thomas|||Dan - You' da man !!! Thanks a lot. Yes, I could launch SSMS as
asministrator, and added my windows login and not everything's just fine.
I really appreciate your help and thank you once again.
Best regards and have a nice day,
Thomas
"Dan Guzman" wrote:
> Can you connect if you launch SSMS with "run as Administrator"? If so, add
> your Windows login to the sysadmin role so that you don't need to run with
> elevated privileges , except when managing services.
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Thomas Vang" <Thomas Vang@.discussions.microsoft.com> wrote in message
> news:6DD3607B-2A9B-4C69-BBBD-61ADA479D211@.microsoft.com...
> > Hi.
> >
> > After re-installing Windows Vista on my PC, I can no longer log on to my
> > local SQL Server 2005 (SP2) (even though my account name is the same for
> > Vista). I can not even connect with a new query, so I can not update user
> > information or anything like that. It gives me this error:
> >
> > Login failed for user 'Thomas-PC\Thomas'. (.Net SqlClient Data Provider)
> >
> > --
> > For help, click:
> > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
> >
> > --
> > Server Name: thomas-pc
> > Error Number: 18456
> > Severity: 14
> > State: 1
> > Line Number: 65536
> >
> > --
> > Program Location:
> >
> > at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> > exception, Boolean breakConnection)
> > at
> > System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> > stateObj)
> > at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> > SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> > bulkCopyHandler, TdsParserStateObject stateObj)
> > at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> > enlistOK)
> > at
> > System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> > serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> > timerExpire, SqlConnection owningObject)
> > at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> > host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> > owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
> > at
> > System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> > owningObject, SqlConnectionString connectionOptions, String newPassword,
> > Boolean redirectedUserInstance)
> > at
> > System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> > identity, SqlConnectionString connectionOptions, Object providerInfo,
> > String
> > newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
> > at
> > System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> > options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> > owningConnection)
> > at
> > System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
> > owningConnection, DbConnectionPoolGroup poolGroup)
> > at
> > System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> > owningConnection)
> > at
> > System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> > outerConnection, DbConnectionFactory connectionFactory)
> > at System.Data.SqlClient.SqlConnection.Open()
> > at
> > Microsoft.SqlServer.Management.UI.ConnectionDlg.NewRegisteredServerForm.testConnection_Click(Object
> > sender, EventArgs e)
> >
> > Unfortunately the link provided above for more help takes me to a page
> > that
> > does not exist.
> > I did try to uninstall the SQL Server 2005 and re-install it again but
> > without any difference.
> > I can connect to servers on other servers, but as I mentioned not my local
> > SQL server.
> >
> > Thanks for your advise/help,
> > Thomas
>|||I'm glad I was able to help you out, Thomas. IIRC, the SP2 install can also
add logins to the sysadmin role so you don't need to do it manually.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Thomas Vang" <ThomasVang@.discussions.microsoft.com> wrote in message
news:978F3942-1196-4598-865E-A7A68295A4CD@.microsoft.com...
> Dan - You' da man !!! Thanks a lot. Yes, I could launch SSMS as
> asministrator, and added my windows login and not everything's just fine.
> I really appreciate your help and thank you once again.
> Best regards and have a nice day,
> Thomas
>
> "Dan Guzman" wrote:
>> Can you connect if you launch SSMS with "run as Administrator"? If so,
>> add
>> your Windows login to the sysadmin role so that you don't need to run
>> with
>> elevated privileges , except when managing services.
>>
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "Thomas Vang" <Thomas Vang@.discussions.microsoft.com> wrote in message
>> news:6DD3607B-2A9B-4C69-BBBD-61ADA479D211@.microsoft.com...
>> > Hi.
>> >
>> > After re-installing Windows Vista on my PC, I can no longer log on to
>> > my
>> > local SQL Server 2005 (SP2) (even though my account name is the same
>> > for
>> > Vista). I can not even connect with a new query, so I can not update
>> > user
>> > information or anything like that. It gives me this error:
>> >
>> > Login failed for user 'Thomas-PC\Thomas'. (.Net SqlClient Data
>> > Provider)
>> >
>> > --
>> > For help, click:
>> > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
>> >
>> > --
>> > Server Name: thomas-pc
>> > Error Number: 18456
>> > Severity: 14
>> > State: 1
>> > Line Number: 65536
>> >
>> > --
>> > Program Location:
>> >
>> > at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
>> > exception, Boolean breakConnection)
>> > at
>> > System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
>> > stateObj)
>> > at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
>> > SqlCommand cmdHandler, SqlDataReader dataStream,
>> > BulkCopySimpleResultSet
>> > bulkCopyHandler, TdsParserStateObject stateObj)
>> > at
>> > System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
>> > enlistOK)
>> > at
>> > System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
>> > serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
>> > timerExpire, SqlConnection owningObject)
>> > at
>> > System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
>> > host, String newPassword, Boolean redirectedUserInstance, SqlConnection
>> > owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
>> > at
>> > System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
>> > owningObject, SqlConnectionString connectionOptions, String
>> > newPassword,
>> > Boolean redirectedUserInstance)
>> > at
>> > System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
>> > identity, SqlConnectionString connectionOptions, Object providerInfo,
>> > String
>> > newPassword, SqlConnection owningObject, Boolean
>> > redirectedUserInstance)
>> > at
>> > System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
>> > options, Object poolGroupProviderInfo, DbConnectionPool pool,
>> > DbConnection
>> > owningConnection)
>> > at
>> > System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
>> > owningConnection, DbConnectionPoolGroup poolGroup)
>> > at
>> > System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
>> > owningConnection)
>> > at
>> > System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
>> > outerConnection, DbConnectionFactory connectionFactory)
>> > at System.Data.SqlClient.SqlConnection.Open()
>> > at
>> > Microsoft.SqlServer.Management.UI.ConnectionDlg.NewRegisteredServerForm.testConnection_Click(Object
>> > sender, EventArgs e)
>> >
>> > Unfortunately the link provided above for more help takes me to a page
>> > that
>> > does not exist.
>> > I did try to uninstall the SQL Server 2005 and re-install it again but
>> > without any difference.
>> > I can connect to servers on other servers, but as I mentioned not my
>> > local
>> > SQL server.
>> >
>> > Thanks for your advise/help,
>> > Thomas
>>|||Thanks Dan! This helped with me running into issues when trying to restart
my SQL Server 2005 Developer Edition instance on Vista Business and failing
due to authentication issues, even though I am an administrator on my
workstation.
Laurence
"Dan Guzman" wrote:
> Can you connect if you launch SSMS with "run as Administrator"? If so, add
> your Windows login to the sysadmin role so that you don't need to run with
> elevated privileges , except when managing services.
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Thomas Vang" <Thomas Vang@.discussions.microsoft.com> wrote in message
> news:6DD3607B-2A9B-4C69-BBBD-61ADA479D211@.microsoft.com...
> > Hi.
> >
> > After re-installing Windows Vista on my PC, I can no longer log on to my
> > local SQL Server 2005 (SP2) (even though my account name is the same for
> > Vista). I can not even connect with a new query, so I can not update user
> > information or anything like that. It gives me this error:
> >
> > Login failed for user 'Thomas-PC\Thomas'. (.Net SqlClient Data Provider)
> >
> > --
> > For help, click:
> > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
> >
> > --
> > Server Name: thomas-pc
> > Error Number: 18456
> > Severity: 14
> > State: 1
> > Line Number: 65536
> >
> > --
> > Program Location:
> >
> > at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> > exception, Boolean breakConnection)
> > at
> > System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
> > stateObj)
> > at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> > SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
> > bulkCopyHandler, TdsParserStateObject stateObj)
> > at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
> > enlistOK)
> > at
> > System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
> > serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
> > timerExpire, SqlConnection owningObject)
> > at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
> > host, String newPassword, Boolean redirectedUserInstance, SqlConnection
> > owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
> > at
> > System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
> > owningObject, SqlConnectionString connectionOptions, String newPassword,
> > Boolean redirectedUserInstance)
> > at
> > System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
> > identity, SqlConnectionString connectionOptions, Object providerInfo,
> > String
> > newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
> > at
> > System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
> > options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
> > owningConnection)
> > at
> > System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
> > owningConnection, DbConnectionPoolGroup poolGroup)
> > at
> > System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
> > owningConnection)
> > at
> > System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
> > outerConnection, DbConnectionFactory connectionFactory)
> > at System.Data.SqlClient.SqlConnection.Open()
> > at
> > Microsoft.SqlServer.Management.UI.ConnectionDlg.NewRegisteredServerForm.testConnection_Click(Object
> > sender, EventArgs e)
> >
> > Unfortunately the link provided above for more help takes me to a page
> > that
> > does not exist.
> > I did try to uninstall the SQL Server 2005 and re-install it again but
> > without any difference.
> > I can connect to servers on other servers, but as I mentioned not my local
> > SQL server.
> >
> > Thanks for your advise/help,
> > Thomas
>

Monday, March 12, 2012

Login error at Microsoft SQl server 2005

when i tried to login at SQL server 2005 by my local account i found an error (i login by the administrator account and use windows authentication) ... can any one help me plz?

Which error did you get ?

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||See this http://msdn2.microsoft.com/en-us/library/ms366351.aspx is any help.

Login Attempt through EM

Strange opportunity here: I have a sql server that I manage it is not in a
domain but uses my domain id for a local login account. ie domain\tbolin,
localserver\tbolin.
I have the SQL registered from my desktop using sa, but idea I know. The
issue is that my local id get locks out. I noticed in the security logs tha
t
my domain account is getting a login failure every 17 seconds, and causes
windows to lock my local account.
How can that be when they are not even connected?
Also why is EM trying to login to the server when it is registered as sa?
THomIt's probably the polling of the services from Enterprise
Manager. Try turning off the polling and see if that makes a
difference.
In Enterprise Manager, go to tools then select options.
Clear the checkbox for Server State Polling on the
General tab.
-Sue
On Fri, 4 Nov 2005 07:59:12 -0800, "Thom"
<Thom@.discussions.microsoft.com> wrote:

>Strange opportunity here: I have a sql server that I manage it is not in a
>domain but uses my domain id for a local login account. ie domain\tbolin,
>localserver\tbolin.
>I have the SQL registered from my desktop using sa, but idea I know. The
>issue is that my local id get locks out. I noticed in the security logs th
at
>my domain account is getting a login failure every 17 seconds, and causes
>windows to lock my local account.
>How can that be when they are not even connected?
>Also why is EM trying to login to the server when it is registered as sa?
>THom

Friday, February 24, 2012

Logic statement using select query

I'd like to make a logic statement, that would take as arguments result of the sql select query. In more details: I would like to create a local Bool variable that would be false if some value is NULL in the table (or select query).

Query example:

select taskID from Users where Login=@.username

Which classes/methods should i use to solve this problem? I use SqlDataSource to get access to database and i think i should use something like SqlDataSource.UpdateCommand and SqlDataSource.UpdateParameters but dont know how to build from this a logic statement.

Thanks in advance

If you are using the SqlDataSource, in its Selected event, you can check the RowsAffected property. If it is > 0, set your bool to true:

bool Check = False;

protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
int RecordCount = e.AffectedRows;

if (RecordCount > 0)
{ Check = True; }
}


|||

Actually I tried to make it in the Page_Load(object sender, EventArgs e) event. Does it change anything?

I'm wondering if there is a way to get to sql query from C# code. Something like:

[for each row from select query]

bool present;

if ( [row.taskID] == null )

{

present = false;

}

|||You will not get rows containing null from the query you showed in your example. You will only get rows that contain the TaskID that belong to the user specified. If there are no TaskIDs for that user, you will get no rows at all.|||

I think i will get a row of some user even if he has NULL in taskID field. I checked this and i got the row that i wanted with empty value of the taskID field.

But even if there would be e.g. -1 the problem still exists and i have no idea how to solve it or even where to look for solution.

|||I beg your pardon. You are right. I didn't read your query correctly. You can access values from a datasource as described here:http://www.mikesdotnetting.com/Article.aspx?ArticleID=45, and check each value, setting your bool accordingly|||

Thaks again, it works fine now. You are gosu ;)

|||

DCVer:

You are gosu ;)

Is that a good thing?Confused

|||

Yes, you are master, the king etcSmile

Logging to Event Viewer "fails" but SQL Server logging works OK - why?

Greetings,

I am developing a package on my local workstation. I have defined two logging service providers. One is for SQL Server and the other is for the Windows Event Log. I am using the Dts.Log method in a script task to write log entries.

Logging is working properly with the SQL Server provider and rows are being inserted into the sysdtslog90 table. However, the only events that are being logged in the Windows Event Log are the package start and end events which I believe SSIS is doing automatically anyway.

Is there something I need to do to enable WIndows Event Log logging other than defining a log provider and making sure it is checked active? Won't SSIS write to two different logs with one Dts.Log call? Any ideas on what might be going wrong with my approach?

Thanks,

BCB

The answer is no - SSIS won't write to the Windows event log with one Dts.Log call. Writing to the event log takes a little more doing. The following code shows a method I used to do logging to the Windows event log. "rowsInserted" is a parameter that is specific to our business requirements. It can be omitted for most uses.

Public Sub WriteEventLogEntry(ByVal logMessage As String, ByVal entryType As EventLogEntryType, ByVal rowsInserted As Integer)

Try

Dim source As String

Dim log As String

Dim machine As String

' get system variables recorded in event log

Dim vars As Variables

Dts.VariableDispenser.LockOneForRead("System:Stick out tongueackageName", vars)

source = vars("PackageName").Value.ToString()

Dts.VariableDispenser.LockOneForRead("System::MachineName", vars)

machine = vars("MachineName").Value.ToString()

' log in Application group

log = "Application"

If Not EventLog.SourceExists(source, machine) Then

EventLog.CreateEventSource(source, log, machine)

End If

Dim eLog As New EventLog(log, machine, source)

If (rowsInserted >= 0) Then

eLog.WriteEntry(logMessage, entryType, rowsInserted)

Else

eLog.WriteEntry(logMessage, entryType) ' log does not allow negative numbers

End If

Catch ex As Exception

' do nothing - let processing continue

End Try

End Sub