Rehan Shikkalgar
Rehan Shikkalgar

Reputation: 1047

Cannot connect to Sql server from .net core application

I am working on .net core application, which will connect to database to fetch records.

here is the connection string:

Server=NEWGGHEG1RDMDBI.id.Test.test1.COM\FF1,3133;Database=T1;Integrated Security=False;User Id=AMR\s_testuser;Password=test@123;Persist Security Info=True;

when i try connecting to database using this connectionstring, it says Login Failed to user 'AMR\s_testuser'.

Username and password which i am passing are correct.

I tried many answers, but nothing worked. Please help me on this. Thank you

Upvotes: 0

Views: 1063

Answers (2)

NuNn DaDdY
NuNn DaDdY

Reputation: 2992

Have you verified that the Domain Account has access to the database server? There should be a corresponding Login on the server for the domain User/Group attempting to connection. In addition to this, there would need to be a database user mapped to the login and granted the appropriate permissions/roles on the target database (T1)

Create a Login

Create a Database User

Give the following connection string a try:

Server=NEWGGHEG1RDMDBI.id.Test.test1.COM\FF1,3133;Database=T1;Integrated Security=True

Upvotes: 0

tj-cappelletti
tj-cappelletti

Reputation: 1864

Based on your comments and your error message, you are using the wrong authentication. If you created the user inside SQL Server then you should be using standard security. If you are using a domain account, which you show in your connection string, you need to be using trusted connection.

Standard

Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;

Trusted

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

Notice that trusted does not pass any credentials where as standard does.

https://www.connectionstrings.com/sql-server/

Upvotes: 0

Related Questions