Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Can not connect to sql server database from web application(Configured in IIS) ---

Can not connect to sql server database from web application(Configured in IIS) ---

Scheduled Pinned Locked Moved Web Development
csharpasp-netdatabasesecuritysql-server
8 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hemant Thaker
    wrote on last edited by
    #1

    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

    D P A 3 Replies Last reply
    0
    • H 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

      D Offline
      D Offline
      DoctorMick
      wrote on last edited by
      #2

      In IIS, untick Anonymous access and check integrated windows authentication in the Directory Security tab.

      H 1 Reply Last reply
      0
      • H 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

        P Offline
        P Offline
        Paddy Boyd
        wrote on last edited by
        #3

        Also make sure you have your web.config set up to use windows authentication and not forms auth.

        H 1 Reply Last reply
        0
        • H 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

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          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

          H 2 Replies Last reply
          0
          • A Abhishek Sur

            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

            H Offline
            H Offline
            Hemant Thaker
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • D DoctorMick

              In IIS, untick Anonymous access and check integrated windows authentication in the Directory Security tab.

              H Offline
              H Offline
              Hemant Thaker
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • P Paddy Boyd

                Also make sure you have your web.config set up to use windows authentication and not forms auth.

                H Offline
                H Offline
                Hemant Thaker
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • A Abhishek Sur

                  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

                  H Offline
                  H Offline
                  Hemant Thaker
                  wrote on last edited by
                  #8

                  Hi... 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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups