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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. MS SQL Connection Failed eg: "Trusted Connection"...

MS SQL Connection Failed eg: "Trusted Connection"...

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
3 Posts 2 Posters 0 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.
  • P Offline
    P Offline
    PDTUM
    wrote on last edited by
    #1

    Hello, I have written an application that needs to connect to a database that I have hosted online. I can connect perfectly using the MS SQL Management Studio, but when I try to connect using my own code, the connection fails and gives the following reason: "The user is not associated with a trusted SQL Server connection" I am using the same login information that I am using with the management studio. This is how the connection string is coded:

    SqlConnection Conn = new SqlConnection("server=" + txtServerName.Text + ";user id=" + txtUID.Text + ";password=" + txtPWD.Text + ";Trusted_Connection=True");

    I am able to connect perfectly on Localhost using a clone of this exact database. Can you explain or correct this problem? Thank you, Pat

    _ 1 Reply Last reply
    0
    • P PDTUM

      Hello, I have written an application that needs to connect to a database that I have hosted online. I can connect perfectly using the MS SQL Management Studio, but when I try to connect using my own code, the connection fails and gives the following reason: "The user is not associated with a trusted SQL Server connection" I am using the same login information that I am using with the management studio. This is how the connection string is coded:

      SqlConnection Conn = new SqlConnection("server=" + txtServerName.Text + ";user id=" + txtUID.Text + ";password=" + txtPWD.Text + ";Trusted_Connection=True");

      I am able to connect perfectly on Localhost using a clone of this exact database. Can you explain or correct this problem? Thank you, Pat

      _ Offline
      _ Offline
      _Damian S_
      wrote on last edited by
      #2

      A trusted connection is useful on a local network, where your windows account is "trusted". For a hosted SQL Server such as the one you described, you would be using a standard connection rather than a trusted one.

      I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!

      P 1 Reply Last reply
      0
      • _ _Damian S_

        A trusted connection is useful on a local network, where your windows account is "trusted". For a hosted SQL Server such as the one you described, you would be using a standard connection rather than a trusted one.

        I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!

        P Offline
        P Offline
        PDTUM
        wrote on last edited by
        #3

        Damian, Thank you for your answer. Actually, I added that on because it wasn't working without it. Now, since it wasn't working with it, I removed it...and now it is working again. I can't explain it, but since it is now working without it, you must be right. I do not know why it would not connect before. I have marked your answer as correct and I appreciate your assistance. Thank You. Best Regards, Pat

        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