0

I have a website where I need to fetch data from a SQL Server 2008 R2 database. But I'm getting an error

Login failed for user 'domain\Username'

I googled for it then I get that to change property of SQL Server -> Properties -> Security -> Server authentication to SQL Server and Windows authentication mode only I'm still getting the same error. I don't want to use ID and password in connection string

My connection string:

<add name="ConnectionString" 
     connectionString="Data Source=servername;Initial Catalog=databasename;Integrated Security=True" 
     providerName="System.Data.SqlClient" />

Please help me.

d0812
  • 5
  • 5
  • 1
    Since your question is product-specific you are more likely to get help if you add the appropriate tag (naming the product) to the question. – Erwin Smout Feb 24 '16 at 08:56
  • @ErwinSmout- no , actually I had host my website on IIS 8 ( localhost). I can fetch data properly if I run code from Visual studio. But it getting error when I try to run from IIS – d0812 Feb 24 '16 at 08:59
  • You got error on IIS because IIS have it own user which will load website. There for you will need add this user to your sql server or to use normal userId/password authentication. – Lesmian Feb 24 '16 at 09:00
  • Is there any other solution, I dont want to use ID, password. my username is already added in server – d0812 Feb 24 '16 at 09:18
  • @d0812 Can you connect your database with SQL Server Management Studio? – Sankar Feb 24 '16 at 09:49
  • @SankarRaj- Yes I can connect database with sql without any ID password. with servername as server name and authentication as windows authentication. – d0812 Feb 24 '16 at 09:55
  • @d0812 what kind of authentication in IIS you use? Anonymous or Basic Authentication? – gofr1 Feb 27 '16 at 15:16

1 Answers1

0

add user id and passsword

or

1) Go to Server Explorer tab on VS

2) In Data Connections right click (click on properties) on your db

3) copy Connection String

Khan Abdulrehman
  • 816
  • 2
  • 10
  • 22