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. ASP.NET
  4. Help Trying Connect to SQL

Help Trying Connect to SQL

Scheduled Pinned Locked Moved ASP.NET
questiondatabasesql-serversysadminhelp
9 Posts 4 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.
  • A Offline
    A Offline
    ALQallaf
    wrote on last edited by
    #1

    Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();

    I C K 3 Replies Last reply
    0
    • A ALQallaf

      Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();

      I Offline
      I Offline
      isroavi
      wrote on last edited by
      #2

      you did not mentioned uid and pwd. or ty OLDDBConneciton object. raj

      A 1 Reply Last reply
      0
      • A ALQallaf

        Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        Does the user your process is running as (ASPNET probably) have permission to log on to the database. By default the answer is no. You must add a login to SQL Server to accept the user you are connecting as. You must also add that user to the database on the server you want to connect to. You have not specified a user in your connection string so I'm guessing that it will just default to trying to use a trusted connection (the error message hints at this also). ASP.NET applications connect using a special locked down account (for security). That account is generally ASPNET, although on some operating systems it will use another account (Win Srv 2003 will use NT AUTHORITY\NETWORK SERVICE)


        "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

        A 1 Reply Last reply
        0
        • C Colin Angus Mackay

          Does the user your process is running as (ASPNET probably) have permission to log on to the database. By default the answer is no. You must add a login to SQL Server to accept the user you are connecting as. You must also add that user to the database on the server you want to connect to. You have not specified a user in your connection string so I'm guessing that it will just default to trying to use a trusted connection (the error message hints at this also). ASP.NET applications connect using a special locked down account (for security). That account is generally ASPNET, although on some operating systems it will use another account (Win Srv 2003 will use NT AUTHORITY\NETWORK SERVICE)


          "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

          A Offline
          A Offline
          ALQallaf
          wrote on last edited by
          #4

          im using Authentication: Windows Authentication, so i did not entered username or password , for this reasone i did not specified a user in my conection string, i dont know if i have to put a user , if yes i have to then what is my user will be ? thanks

          C 1 Reply Last reply
          0
          • I isroavi

            you did not mentioned uid and pwd. or ty OLDDBConneciton object. raj

            A Offline
            A Offline
            ALQallaf
            wrote on last edited by
            #5

            im using Windows Authentication so what is my user id and password will be ?

            C 1 Reply Last reply
            0
            • A ALQallaf

              im using Windows Authentication so what is my user id and password will be ?

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              If you are using Windows Authentication then you do not pass a user name and password.


              "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

              1 Reply Last reply
              0
              • A ALQallaf

                im using Authentication: Windows Authentication, so i did not entered username or password , for this reasone i did not specified a user in my conection string, i dont know if i have to put a user , if yes i have to then what is my user will be ? thanks

                C Offline
                C Offline
                Colin Angus Mackay
                wrote on last edited by
                #7

                You might find this article useful: How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0[^]


                "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

                1 Reply Last reply
                0
                • A ALQallaf

                  Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();

                  K Offline
                  K Offline
                  Kanjinghat
                  wrote on last edited by
                  #8

                  the connection string should include "Integrated Security=SSPI". that is SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; Integrated Security=SSPI " ); hope this will help you. Cheers Ramesh.Kanjinghat

                  A 1 Reply Last reply
                  0
                  • K Kanjinghat

                    the connection string should include "Integrated Security=SSPI". that is SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; Integrated Security=SSPI " ); hope this will help you. Cheers Ramesh.Kanjinghat

                    A Offline
                    A Offline
                    ALQallaf
                    wrote on last edited by
                    #9

                    but your answer too late :), i already did it, any way thanks :-O

                    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