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. General Programming
  3. C#
  4. SQL Server 2008 Connection Problem

SQL Server 2008 Connection Problem

Scheduled Pinned Locked Moved C#
helpdatabasesql-serversysadminbusiness
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.
  • M Offline
    M Offline
    musefan
    wrote on last edited by
    #1

    Hi all, I have an application that attemps to connect to a database. I have one machine running XP that connects to a server machine with SQL server 2005 installed. In this instance i can connect every time, any time with no issues. My second machine is running Vista Business SP1, and connects to a server with SQL Server 2008 installed. I had spent alot of time trying to get the application to connect to the database as I initially had an 'error: 26 - Error Locating Server/Instance Specified' message. so i did the research on that and all suggestions seemed to already be applied in my case. Anyway after a number of hours after server restart it works. The next day, application failed again. I did a server restart and did not work for while, but then it started to connect again, then stopped again. Basically with no change to the application its working sometimes but not others. If i use command prompt and 'osql' commands i am always able to detect the server\instance i want, and i can also retrieve data from it. so i cant see how it is a server setup issue. but if it is a programming issues why would it work sometimes and not others. Does anyone know of any extra coding required when working the SQL server 2008, over 2005 my relevant code is as simple as follows. connection string is: Server=\;Database=;User Id=;Password=; using System.Data.SqlClient; SqlConnection connection = new SqlConnection(@connectionString); connection.Open(); Any help or suggestion will be great Thanks

    S M W 4 Replies Last reply
    0
    • M musefan

      Hi all, I have an application that attemps to connect to a database. I have one machine running XP that connects to a server machine with SQL server 2005 installed. In this instance i can connect every time, any time with no issues. My second machine is running Vista Business SP1, and connects to a server with SQL Server 2008 installed. I had spent alot of time trying to get the application to connect to the database as I initially had an 'error: 26 - Error Locating Server/Instance Specified' message. so i did the research on that and all suggestions seemed to already be applied in my case. Anyway after a number of hours after server restart it works. The next day, application failed again. I did a server restart and did not work for while, but then it started to connect again, then stopped again. Basically with no change to the application its working sometimes but not others. If i use command prompt and 'osql' commands i am always able to detect the server\instance i want, and i can also retrieve data from it. so i cant see how it is a server setup issue. but if it is a programming issues why would it work sometimes and not others. Does anyone know of any extra coding required when working the SQL server 2008, over 2005 my relevant code is as simple as follows. connection string is: Server=\;Database=;User Id=;Password=; using System.Data.SqlClient; SqlConnection connection = new SqlConnection(@connectionString); connection.Open(); Any help or suggestion will be great Thanks

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, your connection string looks kind of strange to me. Are you sure that this is correct. I'm missing the servername\instancename... Regards Sebastian

      It's not a bug, it's a feature! Me in Softwareland.

      1 Reply Last reply
      0
      • M musefan

        Hi all, I have an application that attemps to connect to a database. I have one machine running XP that connects to a server machine with SQL server 2005 installed. In this instance i can connect every time, any time with no issues. My second machine is running Vista Business SP1, and connects to a server with SQL Server 2008 installed. I had spent alot of time trying to get the application to connect to the database as I initially had an 'error: 26 - Error Locating Server/Instance Specified' message. so i did the research on that and all suggestions seemed to already be applied in my case. Anyway after a number of hours after server restart it works. The next day, application failed again. I did a server restart and did not work for while, but then it started to connect again, then stopped again. Basically with no change to the application its working sometimes but not others. If i use command prompt and 'osql' commands i am always able to detect the server\instance i want, and i can also retrieve data from it. so i cant see how it is a server setup issue. but if it is a programming issues why would it work sometimes and not others. Does anyone know of any extra coding required when working the SQL server 2008, over 2005 my relevant code is as simple as follows. connection string is: Server=\;Database=;User Id=;Password=; using System.Data.SqlClient; SqlConnection connection = new SqlConnection(@connectionString); connection.Open(); Any help or suggestion will be great Thanks

        M Offline
        M Offline
        musefan
        wrote on last edited by
        #3

        Sorry, it didnt display how i typed it. the blank values do have data in: Server=server\instance;Database=database;User Id=username;Password=password; the Bold values are masked as i have said i did manage to connect a couple of times, with the same connection string, so i cant see that being an issue thanks

        C 1 Reply Last reply
        0
        • M musefan

          Sorry, it didnt display how i typed it. the blank values do have data in: Server=server\instance;Database=database;User Id=username;Password=password; the Bold values are masked as i have said i did manage to connect a couple of times, with the same connection string, so i cant see that being an issue thanks

          C Offline
          C Offline
          Charith Jayasundara
          wrote on last edited by
          #4

          Hi, try this .. connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Pwd=password"

          Charith Jayasundara

          M 1 Reply Last reply
          0
          • C Charith Jayasundara

            Hi, try this .. connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Pwd=password"

            Charith Jayasundara

            M Offline
            M Offline
            musefan
            wrote on last edited by
            #5

            Hi Charith, Thanks for your input. As I said in my post. My application connects sometimes and not others. At the minute it is working, so I can verify that your connection string suggestion is valid. but so is the connection string I was originally using so I can not say that my solution is solved.

            1 Reply Last reply
            0
            • M musefan

              Hi all, I have an application that attemps to connect to a database. I have one machine running XP that connects to a server machine with SQL server 2005 installed. In this instance i can connect every time, any time with no issues. My second machine is running Vista Business SP1, and connects to a server with SQL Server 2008 installed. I had spent alot of time trying to get the application to connect to the database as I initially had an 'error: 26 - Error Locating Server/Instance Specified' message. so i did the research on that and all suggestions seemed to already be applied in my case. Anyway after a number of hours after server restart it works. The next day, application failed again. I did a server restart and did not work for while, but then it started to connect again, then stopped again. Basically with no change to the application its working sometimes but not others. If i use command prompt and 'osql' commands i am always able to detect the server\instance i want, and i can also retrieve data from it. so i cant see how it is a server setup issue. but if it is a programming issues why would it work sometimes and not others. Does anyone know of any extra coding required when working the SQL server 2008, over 2005 my relevant code is as simple as follows. connection string is: Server=\;Database=;User Id=;Password=; using System.Data.SqlClient; SqlConnection connection = new SqlConnection(@connectionString); connection.Open(); Any help or suggestion will be great Thanks

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              This could be a connection pool issue. Have you tried disabling connection pool; Specify Pooling=false to your connection string and test if it has any effect. Also is the message 'error: 26 - Error Locating Server/Instance Specified' still the one you receive or are you getting any other messages.

              The need to optimize rises from a bad design.My articles[^]

              M 1 Reply Last reply
              0
              • W Wendelius

                This could be a connection pool issue. Have you tried disabling connection pool; Specify Pooling=false to your connection string and test if it has any effect. Also is the message 'error: 26 - Error Locating Server/Instance Specified' still the one you receive or are you getting any other messages.

                The need to optimize rises from a bad design.My articles[^]

                M Offline
                M Offline
                musefan
                wrote on last edited by
                #7

                Thanks for your reply Mika, Curently my application is connecting and setting the Pooling=False has no noticable affect. From what I just read about Pooling thou, it seems best to leave this at the default 'True' value as it can improve performance with database applications the use the same connection strings over and over again. (http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx[^]) Whenever I cannot connect the 'error: 26' message is the only one I have ever recieved in regards to this issue. At the moment the application has been able to connect with no errors since last night, so fingers crossed that it stays that way :P If the problem has been solved in my case then I can only conclude that there was an issue with some server setting. If I manage to find a definative answer to my problem I will post my findings here.

                W 1 Reply Last reply
                0
                • M musefan

                  Thanks for your reply Mika, Curently my application is connecting and setting the Pooling=False has no noticable affect. From what I just read about Pooling thou, it seems best to leave this at the default 'True' value as it can improve performance with database applications the use the same connection strings over and over again. (http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx[^]) Whenever I cannot connect the 'error: 26' message is the only one I have ever recieved in regards to this issue. At the moment the application has been able to connect with no errors since last night, so fingers crossed that it stays that way :P If the problem has been solved in my case then I can only conclude that there was an issue with some server setting. If I manage to find a definative answer to my problem I will post my findings here.

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #8

                  musefan wrote:

                  Curently my application is connecting and setting the Pooling=False has no noticable affect

                  Ok, so it seems that the pooling isn't affecting

                  musefan wrote:

                  what I just read about Pooling thou, it seems best to leave this at the default 'True'

                  Absolutely. The idea was just that you should test if the pool acts correctly. In some situations you can end up with connections in the pool but they won't work thus leading to an error.

                  musefan wrote:

                  At the moment the application has been able to connect with no errors since last night, so fingers crossed that it stays that way

                  Let's hope so.

                  The need to optimize rises from a bad design.My articles[^]

                  1 Reply Last reply
                  0
                  • M musefan

                    Hi all, I have an application that attemps to connect to a database. I have one machine running XP that connects to a server machine with SQL server 2005 installed. In this instance i can connect every time, any time with no issues. My second machine is running Vista Business SP1, and connects to a server with SQL Server 2008 installed. I had spent alot of time trying to get the application to connect to the database as I initially had an 'error: 26 - Error Locating Server/Instance Specified' message. so i did the research on that and all suggestions seemed to already be applied in my case. Anyway after a number of hours after server restart it works. The next day, application failed again. I did a server restart and did not work for while, but then it started to connect again, then stopped again. Basically with no change to the application its working sometimes but not others. If i use command prompt and 'osql' commands i am always able to detect the server\instance i want, and i can also retrieve data from it. so i cant see how it is a server setup issue. but if it is a programming issues why would it work sometimes and not others. Does anyone know of any extra coding required when working the SQL server 2008, over 2005 my relevant code is as simple as follows. connection string is: Server=\;Database=;User Id=;Password=; using System.Data.SqlClient; SqlConnection connection = new SqlConnection(@connectionString); connection.Open(); Any help or suggestion will be great Thanks

                    M Offline
                    M Offline
                    musefan
                    wrote on last edited by
                    #9

                    Nope it gave in eventually. Now I am using the server IP address and instance name and worked as soon as I changed it. If this lasts then there must be some issue with resolving the DSN at some times and not other. Any ideas on this?

                    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