Can't Connect to SQL db

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DanWeaver

    Can't Connect to SQL db

    Going a bit crazy. Have sqlserver all installed and running. I have a
    security problem I think- have read many other news posts that SOUND
    similar but e.g. My SQL Server configuration manager doesnt seem to
    have seccurity options let alone offer the possibility of allowing a
    'mix' of SQL/ windows requests.

    For logon in SQL Server configuration manager 'built- in account'
    local system is selected rather than the 'this account' option which
    has stars in the password field and no username options.

    This is myconnection string: kris\ is this local machine

    myConnection = New SqlConnection(" server=kris
    \SQLEXPRESS;uid =sa;pwd=;databa se=pubs")

    This is the error I get
    System.Data.Sql Client.SqlExcep tion was unhandled
    Class=14
    ErrorCode=-2146232060
    LineNumber=6553 6
    Message="Login failed for user 'sa'. The user is not associated with
    a trusted SQL Server connection."
    Number=18452
    Procedure=""
    Server="kris\SQ LEXPRESS"

    Any ideas?

  • Erland Sommarskog

    #2
    Re: Can't Connect to SQL db

    DanWeaver (danofweaver@go oglemail.com) writes:
    This is myconnection string: kris\ is this local machine
    >
    myConnection = New SqlConnection(" server=kris
    \SQLEXPRESS;uid =sa;pwd=;databa se=pubs")
    >
    This is the error I get
    System.Data.Sql Client.SqlExcep tion was unhandled
    Class=14
    ErrorCode=-2146232060
    LineNumber=6553 6
    Message="Login failed for user 'sa'. The user is not associated with
    a trusted SQL Server connection."
    Number=18452
    Procedure=""
    Server="kris\SQ LEXPRESS"
    Have you enabled you server for SQL authetnication? By default,
    SQL Server permits only Window authentication.

    Do you have any particular reason you want to use SQL authentication?
    Else, change "uid=sa;pwd =" to "Integrated Security=SSPI".
    For logon in SQL Server configuration manager 'built- in account'
    local system is selected rather than the 'this account' option which
    has stars in the password field and no username options.
    Note that his is about how SQL Server logs into Windows. That's a
    different thing.


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server 2005 at

    Books Online for SQL Server 2000 at

    Comment

    • DanWeaver

      #3
      Re: Can't Connect to SQL db

      Do you have any particular reason you want to use SQL authentication?
      Else, change "uid=sa;pwd =" to "Integrated Security=SSPI".
      Thanks, Erland. That helped move me on- in fact the first time I tried
      it it seemed to work (though my record was not added- posibly as there
      already existed a record with same id) Anyway- I cant experiment with
      that cos shorlty after I could no longer connect- seems strange- I
      checked the table after first successful run to see if it had updated
      and ran the code again- got a message "another process is locking the
      db"- great I thought- all is working- and closed the connection in
      VS-
      now though the connection gets stuck at login and says:

      Cannot open database "pubs" requested by the login. The login failed.
      Login failed for user 'KRISLAPTOP\Kri s'.






      Comment

      • Erland Sommarskog

        #4
        Re: Can't Connect to SQL db

        DanWeaver (danofweaver@go oglemail.com) writes:
        >Do you have any particular reason you want to use SQL authentication?
        >Else, change "uid=sa;pwd =" to "Integrated Security=SSPI".
        >
        Thanks, Erland. That helped move me on- in fact the first time I tried
        it it seemed to work (though my record was not added- posibly as there
        already existed a record with same id) Anyway- I cant experiment with
        that cos shorlty after I could no longer connect- seems strange- I
        checked the table after first successful run to see if it had updated
        and ran the code again- got a message "another process is locking the
        db"- great I thought- all is working- and closed the connection in
        VS-
        now though the connection gets stuck at login and says:
        >
        Cannot open database "pubs" requested by the login. The login failed.
        Login failed for user 'KRISLAPTOP\Kri s'.
        Seems like that either your user is not present in the pubs database,
        or the database has somehow gone away.


        --
        Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

        Books Online for SQL Server 2005 at

        Books Online for SQL Server 2000 at

        Comment

        • DanWeaver

          #5
          Re: Can't Connect to SQL db

          Thanks, Erland. Something fishy was ocurring with the dbs- deleted
          them and reconnected and set permissions again- seems to work now.

          Cheers, more challenging questions (when I am more informed!) will
          probably follow.

          Dan
          Seems like that either your user is not present in the pubs database,
          or the database has somehow gone away.
          >
          --
          Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se
          >
          Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
          Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx

          Comment

          Working...