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. sql server connection problems

sql server connection problems

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdatabasesql-serversysadmin
7 Posts 3 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.
  • N Offline
    N Offline
    neoms21
    wrote on last edited by
    #1

    Hi , I am trying to connect to SQL server through ado.net. When I make the connection using ‘tools ‘ msg shows that test connection succeeded. But when that same connection is used in the code, Error message pops up saying that sql server doesn’t exist or access denied. If anyone can help me in this regard, I’ll be thankful. neoms21

    P C 2 Replies Last reply
    0
    • N neoms21

      Hi , I am trying to connect to SQL server through ado.net. When I make the connection using ‘tools ‘ msg shows that test connection succeeded. But when that same connection is used in the code, Error message pops up saying that sql server doesn’t exist or access denied. If anyone can help me in this regard, I’ll be thankful. neoms21

      P Offline
      P Offline
      phimix
      wrote on last edited by
      #2

      How do you use the connection in the code?

      1 Reply Last reply
      0
      • N neoms21

        Hi , I am trying to connect to SQL server through ado.net. When I make the connection using ‘tools ‘ msg shows that test connection succeeded. But when that same connection is used in the code, Error message pops up saying that sql server doesn’t exist or access denied. If anyone can help me in this regard, I’ll be thankful. neoms21

        C Offline
        C Offline
        chandru_inbox
        wrote on last edited by
        #3

        Pls Use this Code C# using System.Data; using System.Data.SqlClient; DataSet ds=new DataSet(); SqlConnection con=new SqlConnection("server=urservername;database=urdatabase;User Id=sa;password=;"); private void Page_Load(object sender, System.EventArgs e) { bind(); } public void bind() { con.Open();//when it needs DataSet ds=new DataSet(); SqlDataAdapter ap=new SqlDataAdapter("select * from region",con); ap.Fill(ds); DataGrid1.DataSource=ds.Tables[0].DefaultView; DataGrid1.DataBind(); }

        P 1 Reply Last reply
        0
        • C chandru_inbox

          Pls Use this Code C# using System.Data; using System.Data.SqlClient; DataSet ds=new DataSet(); SqlConnection con=new SqlConnection("server=urservername;database=urdatabase;User Id=sa;password=;"); private void Page_Load(object sender, System.EventArgs e) { bind(); } public void bind() { con.Open();//when it needs DataSet ds=new DataSet(); SqlDataAdapter ap=new SqlDataAdapter("select * from region",con); ap.Fill(ds); DataGrid1.DataSource=ds.Tables[0].DefaultView; DataGrid1.DataBind(); }

          P Offline
          P Offline
          phimix
          wrote on last edited by
          #4

          Looks ok to me, exactely what line does it fail on? I would expect connection string problems if it fails on "con.Open()".

          N 1 Reply Last reply
          0
          • P phimix

            Looks ok to me, exactely what line does it fail on? I would expect connection string problems if it fails on "con.Open()".

            N Offline
            N Offline
            neoms21
            wrote on last edited by
            #5

            i am using the same code but in vb.net (i dont think that makes any diff) yeah it fails exactly on con.open () but whts the problem with connection string i am using pretty much same connection string as in this code. thnkx all for your responses , i except your replies sooner than later neoms21

            P 1 Reply Last reply
            0
            • N neoms21

              i am using the same code but in vb.net (i dont think that makes any diff) yeah it fails exactly on con.open () but whts the problem with connection string i am using pretty much same connection string as in this code. thnkx all for your responses , i except your replies sooner than later neoms21

              P Offline
              P Offline
              phimix
              wrote on last edited by
              #6

              "pretty much the same" - what does that mean? Have you checked: - server name correct? - database name correct? - username correct? - password correct? - user have the necessary rights on sql server? - can you ping the server?

              N 1 Reply Last reply
              0
              • P phimix

                "pretty much the same" - what does that mean? Have you checked: - server name correct? - database name correct? - username correct? - password correct? - user have the necessary rights on sql server? - can you ping the server?

                N Offline
                N Offline
                neoms21
                wrote on last edited by
                #7

                i mean exactly same everything is correct yes i can ping the server.. infact when i test connection from server explorer it shows test connection succeeded. what are all necessary rights which should be provided so that it can be accessed by any user. thnx :) neoms21

                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