error 4060 problem with SQL Express

  • Please, somebody help to resolve the issue.

    Our software uses SQL Server database. All clients have their own database in different cities. Some of them use SQL Express. All of the them suppose to have Windows Authentication.

    Two of them (there are about 15 altogether) have the same problem. They connect OK to the database (!) on the first instance, do something in UI (we run in disconnected mode), than try to save (by connection to the database, of course).

    At than point they have an error:

    Exception type: SqlException

    Exception message: Cannot open database "XXX" requested by the login. The login failed.

    Login failed for user '\'.

    Connection info: Data Source=sbsserver\sqlexpress,2354;Initial Catalog=XXX;Integrated Security=True;Connect Timeout=30

    Number: 4060

    Exception stack trace (if that helps)

    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.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)

    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)

    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)

    at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)

    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

    at System.Data.SqlClient.SqlConnection.Open()

    ......

  • If this is a Winform application you may need to create app.config and put your user information in it, if it is Asp.net then you need to add Asp.net into the SQL Server and the database. The error means the user in context does not have the relevant permission to use SQL Server. The easy fix enable both SQL and Windows authentication and add the users manually into SQL Server and the database.

    Kind regards,
    Gift Peddie

  • Thanks for your reply

    It is winform application.

    The user CONNECTED on the first place to the database, using the same connection string. It means, that he has right to connect. It the second time, when he tries to save, the connection drops.

    Plus, I don't want to add users to the database, it suppose to use their WINDOWS Authentication. And also, I don't have access to thier database to do anything manually

  • It is not as you think there is a user profile file that you need to create that lets all your resources access your user profile so authentication and other premissions related problems are resolved. Check below for what I am trying to explain.

    http://blogs.msdn.com/rprabhu/articles/433979.aspx

    Kind regards,
    Gift Peddie

  • I probably could not explain properly.

    There are more than 10 users, all of which have their own databases and client applications

    All those databases have Windows authentications, none have extra files or extra permissions or app. config entries

    Most work correctly, connecting and disconnesting when required.

    Two of the clients have this problem from TIME to TIME, meaning that in a lot of cases they connect and save and disconnect. If they would not have permissions, they would NEVER connect and NEVER save.

    Best Regards,

    Galina

  • I have understood you from the first post this error comes with specific fix based on the context so let me put it another way you users login info is being dropped and the easy fix is add the users manually in both SQL Server and the database. The config file is the valid techincal solution.

    Kind regards,
    Gift Peddie

  • Let me get it stright

    What you suggest is

    1. enable client's databases to accept either Windows OR SQL Server login

    2. create config file with valid login, which would be accepted by the database

    3. let user usually connect with Windows credentials, but when for whatever reason they dropped, attept to connect, using info from config file

    Is that correct?

  • The config file is more complicated than that, if you change to both Windows and SQL authentication and manually add the user into SQL Server and the database the dropping will stop because your user is now in SQL Server. Now Windows is passing your user sometimes but not always to SQL Server which is saying I don't know this user.

    Kind regards,
    Gift Peddie

  • Sorry, I may be sound stupid, but I did not understand you phrase "database the dropping with stop because your user is now in SQL Server".

    Do you suggest that DB itself read config file to find out credentials? Where is the config file sits? on the client machine? Server? How to do that?

    I read the link you sent me, but there is nothing about the database user settings

    I appreciate your help

    Galina

  • "database the dropping will stop because your user is now in SQL Server".

    I need to proof read my posts but I am saying SQL Server will stop dropping the user information. The config file contains the user profile info which includes the user permissions and the connection string it is supposed to be compiled with the application before deployment. So for now use the solution I gave you or create a context account which your users can use to connect.

    Kind regards,
    Gift Peddie

  • Hi ,

    Just try giving the Ip address of the server in place of servername in DataSource field. Connection info: Data Source=sbsserver\sqlexpress

    Have a nice day !!!

    ----------------------------------------------------------------
    **"There is only one difference between dream and aim. Dream requires Soundless sleep to see…Where as Aim Requires Sleepless Efforts to Achieve":-) **

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply