connect to database using SqlConnection

Discussion in 'MCAD' started by Frank, Feb 12, 2004.

  1. Frank

    Frank Guest

    Hey All,

    I drag a Database Connection from Server Explorer in
    VS.NET to the web form, and it creates the sqlConnection1
    object. I checked the ConnectionString, which seems
    properly. In my code, I called sqlConnection1.Open(). But
    this line generates an exception when running:
    System.Data.SqlClient.SqlException: Login failed for user

    Do I need to setup user/role for aspnet in SQL Manager?
    How can I setup it properly?

    Thanks a million!
    Frank, Feb 12, 2004
    1. Advertisements

  2. Frank

    Kumar Reddi Guest

    The follwing process should correct your problem.. But please make a back up
    copy of machine.config file.. It is always considered to be a good idea when
    you modify critical files like these..

    Assuming you are administrator of the machine...
    open the machine.config file usually located at

    find the following xml element
    <processModel enable="true" timeout="Infinite" idleTimeout="Infinite"

    modify the username attribute as "SYSTEM" instead of the deafult "machine".

    close the machine.config file with the changes saved.. and restart the IIS
    by running the command "issreset.exe" using Start->Run

    I think it should be work.. let me know if it doesnt
    Kumar Reddi, Feb 13, 2004
    1. Advertisements

  3. Frank

    Kumar Reddi Guest

    Even though the above approach works.. some other guy said this is not the
    way to go in real time deployments.. It can lead to security risks..

    You may want to consider the following post ..
    Kumar Reddi, Feb 13, 2004
  4. Frank

    Ryan Walberg Guest

    That is an incredibly bad idea. If the web server is compromised, as it
    often is nowadays, it's running under a privileged account.

    Just add MACHINENAME\ASPNET as a SQL Server login. This has been
    discussed umpteen times.

    P.S. Kumar, what are the IPs of your web servers? I want to, uh, browse
    Ryan Walberg, Feb 13, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.