Connect to SQL Server

Discussion in 'ASP .Net' started by Barry, May 1, 2005.

  1. Barry

    Barry Guest

    Hi

    When trying to connect to SQL Server using the code below i get this message
    at myConnection.Open() line

    Login failed for user 'JACKSON-QS7MHO6H\ASPNET'

    from where does it add \ASPNET
    how do i log on

    string mySelectQuery = "SELECT * FROM authors";
    string myConnectString = "Persist Security Info=False;Integrated
    Security=SSPI;database=pubs;server=JACKSON-QS7MHO6H;";
    SqlCommand myCommand = new SqlCommand(mySelectQuery);
    myCommand.Connection = new SqlConnection(myConnectString);

    SqlConnection myConnection = new SqlConnection(myConnectString);
    myCommand.CommandTimeout = 15;
    myCommand.CommandType = CommandType.Text;
    myConnection.Open();



    Barry
     
    Barry, May 1, 2005
    #1
    1. Advertising

  2. Hi, Barry.

    The issue you're seeing is that your database server doesn't
    have a user named "JACKSON-QS7MHO6H\ASPNET"
    with permissions to access the pubs database.

    Since you're not specifying a username in your connection string,
    the ASP.NET user is the one which attempts to login...and fails.

    Add a user named "JACKSON-QS7MHO6H\ASPNET"
    ( that's "YourMachineName\ASPNET" ) to either SQL Server
    or MSDE ( whichever you're using ) and give it permissions to
    access the pubs database.



    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en Español
    Ven, y hablemos de ASP.NET...
    ======================

    "Barry" <> wrote in message
    news:e%...
    > Hi
    >
    > When trying to connect to SQL Server using the code below i get this message
    > at myConnection.Open() line
    >
    > Login failed for user 'JACKSON-QS7MHO6H\ASPNET'
    >
    > from where does it add \ASPNET
    > how do i log on
    >
    > string mySelectQuery = "SELECT * FROM authors";
    > string myConnectString = "Persist Security Info=False;Integrated
    > Security=SSPI;database=pubs;server=JACKSON-QS7MHO6H;";
    > SqlCommand myCommand = new SqlCommand(mySelectQuery);
    > myCommand.Connection = new SqlConnection(myConnectString);
    >
    > SqlConnection myConnection = new SqlConnection(myConnectString);
    > myCommand.CommandTimeout = 15;
    > myCommand.CommandType = CommandType.Text;
    > myConnection.Open();
    >
    >
    >
    > Barry
    >
    >
    >
     
    Juan T. Llibre, May 1, 2005
    #2
    1. Advertising

  3. Barry you need ASPNET account to log into SQL SERVER(thats the ASPNET
    WORK PROCESS ASP.NET uses).
    Add ASPNET acct to your SQL server.
    Hope that helps
    Patrick



    *** Sent via Developersdex http://www.developersdex.com ***
     
    Patrick Olurotimi Ige, May 1, 2005
    #3
  4. Barry

    Riki Guest

    Barry wrote:
    > Hi
    >
    > When trying to connect to SQL Server using the code below i get this
    > message at myConnection.Open() line
    >
    > Login failed for user 'JACKSON-QS7MHO6H\ASPNET'
    >
    > from where does it add \ASPNET
    > how do i log on
    >
    > string mySelectQuery = "SELECT * FROM authors";
    > string myConnectString = "Persist Security Info=False;Integrated
    > Security=SSPI;database=pubs;server=JACKSON-QS7MHO6H;";
    > SqlCommand myCommand = new SqlCommand(mySelectQuery);
    > myCommand.Connection = new SqlConnection(myConnectString);
    >
    > SqlConnection myConnection = new SqlConnection(myConnectString);
    > myCommand.CommandTimeout = 15;
    > myCommand.CommandType = CommandType.Text;
    > myConnection.Open();


    Apart from allowing access to the ASPNET account (see
    Juan's and Patrick's reply), you may also consider using
    authentication and impersonation. This will make your
    application run under the account that's logged on, and
    if that account has access to your database, it will work.

    Search Google for "ASP.NET impersonation".

    --

    Riki
     
    Riki, May 1, 2005
    #4
  5. Barry

    Barry Guest

    Thanks all,

    I Created a account in SQL Server and that solved the problem

    Barry


    "Riki" <> wrote in message
    news:...
    > Barry wrote:
    > > Hi
    > >
    > > When trying to connect to SQL Server using the code below i get this
    > > message at myConnection.Open() line
    > >
    > > Login failed for user 'JACKSON-QS7MHO6H\ASPNET'
    > >
    > > from where does it add \ASPNET
    > > how do i log on
    > >
    > > string mySelectQuery = "SELECT * FROM authors";
    > > string myConnectString = "Persist Security Info=False;Integrated
    > > Security=SSPI;database=pubs;server=JACKSON-QS7MHO6H;";
    > > SqlCommand myCommand = new SqlCommand(mySelectQuery);
    > > myCommand.Connection = new SqlConnection(myConnectString);
    > >
    > > SqlConnection myConnection = new SqlConnection(myConnectString);
    > > myCommand.CommandTimeout = 15;
    > > myCommand.CommandType = CommandType.Text;
    > > myConnection.Open();

    >
    > Apart from allowing access to the ASPNET account (see
    > Juan's and Patrick's reply), you may also consider using
    > authentication and impersonation. This will make your
    > application run under the account that's logged on, and
    > if that account has access to your database, it will work.
    >
    > Search Google for "ASP.NET impersonation".
    >
    > --
    >
    > Riki
    >
    >
     
    Barry, May 2, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmV6YQ==?=
    Replies:
    3
    Views:
    18,050
    Carlos Barini
    Jun 7, 2004
  2. =?Utf-8?B?UmV6YQ==?=
    Replies:
    2
    Views:
    1,835
    bruce barker
    Jun 8, 2004
  3. Wesley Chen
    Replies:
    0
    Views:
    247
    Wesley Chen
    Apr 7, 2009
  4. Wesley Chen
    Replies:
    9
    Views:
    263
    Sean O'Halpin
    Apr 14, 2009
  5. Replies:
    2
    Views:
    326
Loading...

Share This Page