Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello everyone ,

Here is my problem ,

I develop a form application in my computer. And here is my connection string :

"Server=localhost;Database=atak_db;Trusted_Connection=True;"


and this is works.

Now i want to install this form application at another computer.

Other computer has sql server also and same database has been attached already in this computer.

But my connection string isn't work in this computer. I have tried a lot of things and connectionstrings also.

Do you have any suggestions about this issue ? What can be my problem ? How can i solve this ?
Posted

1 solution

If you have copies the database from your machine to another you may need to change the security.

Bizarrely, if the target server has the same login credentials as the newly attached database, they do not sync. You have to remove the previous credentials and add them back from the server creds.

As you're using Trusted_Connection=True, check the windows account is set up on the db and that it has access writes (or is owner or whatever) of the attached database.

This is an annoyance I have to go through with EVERY db deployment I do >_<

Hope that helps ^_^
Andy

UPDATE:
Step by step:


  1. Open MSSQL Management Studio
  2. Find the database and expand
  3. Expand Security / Users
  4. Delete the windows user account
  5. Under the server:
  6. Expand Security / Logins
  7. If the users windows account is there appear:

    1. Right Click and select Properties

  8. If the account is not there:

    1. Right click the Logins folder
    2. Select New Login
    3. Add the windows user account

  9. Go to User Mapping on the left
  10. check the database to add them to
  11. select the roles they should have
  12. Click OK
br mode="hold" />If all goes to plan then the windows user should be added to the database and the Trusted_Connection=True; should now work
 
Share this answer
 
v2
Comments
kozmikadam 2-Nov-15 6:33am    
Hi Andy ,

I haven't so much experiance with sql server management studio. can you explain step by step ?


I didn't get "remove the previous credentials". Can you explain more ?

There is 2 option in security. One of in my db. And another one in under Databases. And there are 4 users , which one is the windows account ?

Can it be , can't connect to new computers sql server ?
Andy Lanng 2-Nov-15 6:55am    
Please check the updated solution ^_^
kozmikadam 2-Nov-15 6:59am    
Thanks for that ! But i have one more question. Which one is the windows user account ? dbo - guest - INFO SHEMA -sys and i can delete just guest. So can i assume it's the windows account user ?
Andy Lanng 2-Nov-15 7:02am    
It's best to use the named account: so Domain\username

I'm pretty sure it won't exist on either the server or the db
kozmikadam 2-Nov-15 7:07am    
Ok ,i found it under the server > sequrity > logins and i add to my db owner.

But still i can't connect.

Should i make any change in my connection string ?


Here is the error description :

Bu iletişim kutusu yerine JIT hata ayıklamayı çağırma
hakkında detaylı bilgi için bu iletinin sonuna bakın.

************** Özel Durum Metni **************
System.Data.SqlClient.SqlException (0x80131904): Sunucuyla bağlantı kurulurken ağ ile ilgili veya örneğe özel bir hata oluştu. Sunucu bulunamadı veya sunucuya erişilemiyor. Örnek adının doğru olduğunu ve SQL Server'ın uzak bağlantılara izin verdiğini doğrulayın. (provider: Named Pipes Provider, error: 40 - SQL Server için bağlantı açılamadı) ---> System.ComponentModel.Win32Exception (0x80004005): Sistem belirtilen dosyayı bulamıyor
konum: System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
konum: System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
konum: System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
konum: System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
konum: System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
konum: System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
konum: System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken)
konum: System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
konum: System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
konum: System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
konum: System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
konum: System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
konum: System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
konum: System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
konum: System.Data.ProviderBase.DbC

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900