Can not connect to sql server database from web application(Configured in IIS) ---
-
Hi.. My web application is in Visual studio 2005 asp.net/c#. I have sql server 2005 database at back end. When run the project in visual studio my application connects with the database, but i have configured the website in local IIS, the website runs but it does not connect to the database. I am getting following error: Cannot open database "db1" requested by the login. The login failed. Login failed for user 'HEM-BE419D4FB41\ASPNET' I am using Windows authentication to connect to sql server. my connection string is as follows "Data Source=HEM-BE419D4FB41;Initial Catalog=db1;Integrated Security=True" Please tell me the solution thanks, Hemant Thaker
By: Hemant Thaker
-
Hi.. My web application is in Visual studio 2005 asp.net/c#. I have sql server 2005 database at back end. When run the project in visual studio my application connects with the database, but i have configured the website in local IIS, the website runs but it does not connect to the database. I am getting following error: Cannot open database "db1" requested by the login. The login failed. Login failed for user 'HEM-BE419D4FB41\ASPNET' I am using Windows authentication to connect to sql server. my connection string is as follows "Data Source=HEM-BE419D4FB41;Initial Catalog=db1;Integrated Security=True" Please tell me the solution thanks, Hemant Thaker
By: Hemant Thaker
In IIS, untick Anonymous access and check integrated windows authentication in the Directory Security tab.
-
Hi.. My web application is in Visual studio 2005 asp.net/c#. I have sql server 2005 database at back end. When run the project in visual studio my application connects with the database, but i have configured the website in local IIS, the website runs but it does not connect to the database. I am getting following error: Cannot open database "db1" requested by the login. The login failed. Login failed for user 'HEM-BE419D4FB41\ASPNET' I am using Windows authentication to connect to sql server. my connection string is as follows "Data Source=HEM-BE419D4FB41;Initial Catalog=db1;Integrated Security=True" Please tell me the solution thanks, Hemant Thaker
By: Hemant Thaker
Also make sure you have your web.config set up to use windows authentication and not forms auth.
-
Hi.. My web application is in Visual studio 2005 asp.net/c#. I have sql server 2005 database at back end. When run the project in visual studio my application connects with the database, but i have configured the website in local IIS, the website runs but it does not connect to the database. I am getting following error: Cannot open database "db1" requested by the login. The login failed. Login failed for user 'HEM-BE419D4FB41\ASPNET' I am using Windows authentication to connect to sql server. my connection string is as follows "Data Source=HEM-BE419D4FB41;Initial Catalog=db1;Integrated Security=True" Please tell me the solution thanks, Hemant Thaker
By: Hemant Thaker
Just add a new User for HEM-BE419D4FB41\ASPNET on the database db1. If there is no Login created for ASPNET user in your current database instance, you need to create a login account as well.
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET Templates -
Just add a new User for HEM-BE419D4FB41\ASPNET on the database db1. If there is no Login created for ASPNET user in your current database instance, you need to create a login account as well.
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET TemplatesHi... thanks for the response... I have same project in two machines. one has sql server 2005 and the other has sql server express. It works fine where i have Sql server 2005 but not in other. what happens is.. when i browse my website from IIS it prompts me to auto generated login screen with heading "connect to XPW(machine_name)" with username and pwd...so whats going on can u tell me. i could connect to database by doing some changes like... identity impersonate=true, IIS virtual directory -> security -> windows authentication ... etc... etc... so it works fine in that particular machine, and the other has the same settings... the difference is only the edition of sqlserver/ express.... so why it gives me the prompt for login... plz help me out thanks, hemant
By: Hemant Thaker
-
In IIS, untick Anonymous access and check integrated windows authentication in the Directory Security tab.
Hi... thanks for the response... I have same project in two machines. one has sql server 2005 and the other has sql server express. It works fine where i have Sql server 2005 but not in other. what happens is.. when i browse my website from IIS it prompts me to auto generated login screen with heading "connect to XPW(machine_name)" with username and pwd...so whats going on can u tell me. i could connect to database by doing some changes like... identity impersonate=true, IIS virtual directory -> security -> windows authentication ... etc... etc... so it works fine in that particular machine, and the other has the same settings... the difference is only the edition of sqlserver/ express.... so why it gives me the prompt for login... plz help me out thanks, hemant
By: Hemant Thaker
-
Also make sure you have your web.config set up to use windows authentication and not forms auth.
Hi... thanks for the response... I have same project in two machines. one has sql server 2005 and the other has sql server express. It works fine where i have Sql server 2005 but not in other. what happens is.. when i browse my website from IIS it prompts me to auto generated login screen with heading "connect to XPW(machine_name)" with username and pwd...so whats going on can u tell me. i could connect to database by doing some changes like... identity impersonate=true, IIS virtual directory -> security -> windows authentication ... etc... etc... so it works fine in that particular machine, and the other has the same settings... the difference is only the edition of sqlserver/ express.... so why it gives me the prompt for login... plz help me out thanks, hemant
By: Hemant Thaker
-
Just add a new User for HEM-BE419D4FB41\ASPNET on the database db1. If there is no Login created for ASPNET user in your current database instance, you need to create a login account as well.
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET TemplatesHi... As u said, was right but was not getting my way out creating users and logins.I did search something and its like as follows Enabling SQL Authentication STEP1: You need to enable SQL Authentication on the machine. This is complex in SQLExpress and you need to edit the registry. Copy the following lines of text onto a Notepad and save it with extention .REG. -------------COPY BELOW--------------------------------- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer] "LoginMode"=dword:00000002 -------------COPY TILL THIS--------------------------------- STEP2: Double Click on the .REG file to change the registry. This change the Authentication Mode to enable SQL Authentication. STEP3: Restart the SQL Server Express Service or reboot the machine for registry change to take effect. Next, you need to add a user with SQLLogin. To do this: Login to SQLExpress using Express Manager and run the script below: ------------------------------------------- USE MASTER sp_addLogin 'aspuser', 'aspuser@123' GO sp_addsrvrolemember 'aspuser', 'sysadmin' GO USE Cartridge EXEC sp_adduser 'aspuser' ------------------------------------------- In case you want to reduce the privilege for the user then you can specify something other than sysadmin, but we can think of that once this works. Now change your connection string as follows: connectionString = "server=.\\SQLExpress;uid=aspuser;pwd=aspuser@123;database=cartridge;"; //////////////////////////////////////// U may need to change connectionstring probably remove one '\' from server name May be this can help someone... thanks for ur support Hemant
By: Hemant Thaker