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. Visual Basic
  4. Server Connectivity if no server exist

Server Connectivity if no server exist

Scheduled Pinned Locked Moved Visual Basic
helpdatabasecsharpsql-server
3 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.
  • P Offline
    P Offline
    pdnet
    wrote on last edited by
    #1

    Hi All, I am using vb.net 3.5 and Sql Server 2005 There is no problem with connection if Server Name and Database Name Exist. But the Error occurs when Try to connect the server which is not available. then my application goes hang. It is continue Searching. I'm using : Public Sub ConnectConfig(ByVal DSource As String, Optional ByVal Uid As String = "", _ Optional ByVal Pwd As String = "", _ Optional ByVal InCat As String = "", _ Optional ByVal AuthType As String = "") Dim ConnString As String = "" If FrmConfigSetup.cbAuth.SelectedIndex = 0 Then ConnString = "Data Source=" & DSource & ";Initial Catalog=" & InCat & ";Integrated Security=True;Timeout=60;" & "" Else ConnString = "Data Source=" & DSource & ";Initial Catalog=" & InCat & ";Uid=" & Uid & ";Pwd=" & Pwd & ";Timeout=60;" End If SQLConn = New SqlClient.SqlConnection(ConnString) If SQLConn.State = ConnectionState.Open Then SQLConn.Close() SQLConn.Open() Else SQLConn.Open() End If End Sub when it'sTrying to open the connection then goes hang. So, What can I do , please help me.

    Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)

    D S 2 Replies Last reply
    0
    • P pdnet

      Hi All, I am using vb.net 3.5 and Sql Server 2005 There is no problem with connection if Server Name and Database Name Exist. But the Error occurs when Try to connect the server which is not available. then my application goes hang. It is continue Searching. I'm using : Public Sub ConnectConfig(ByVal DSource As String, Optional ByVal Uid As String = "", _ Optional ByVal Pwd As String = "", _ Optional ByVal InCat As String = "", _ Optional ByVal AuthType As String = "") Dim ConnString As String = "" If FrmConfigSetup.cbAuth.SelectedIndex = 0 Then ConnString = "Data Source=" & DSource & ";Initial Catalog=" & InCat & ";Integrated Security=True;Timeout=60;" & "" Else ConnString = "Data Source=" & DSource & ";Initial Catalog=" & InCat & ";Uid=" & Uid & ";Pwd=" & Pwd & ";Timeout=60;" End If SQLConn = New SqlClient.SqlConnection(ConnString) If SQLConn.State = ConnectionState.Open Then SQLConn.Close() SQLConn.Open() Else SQLConn.Open() End If End Sub when it'sTrying to open the connection then goes hang. So, What can I do , please help me.

      Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The timeout in the connection string is used for responses to command queries. It does not apply to the connection itself. Your connection attempt can take a few minutes to timeout and throw an exception.

      pdnet wrote:

      If SQLConn.State = ConnectionState.Open Then SQLConn.Close() SQLConn.Open() Else SQLConn.Open() End If

      What the heck is this?? Since you're creating a new connection object all the time, you just need to Open it. A new connection object's state is always going to be Closed.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      1 Reply Last reply
      0
      • P pdnet

        Hi All, I am using vb.net 3.5 and Sql Server 2005 There is no problem with connection if Server Name and Database Name Exist. But the Error occurs when Try to connect the server which is not available. then my application goes hang. It is continue Searching. I'm using : Public Sub ConnectConfig(ByVal DSource As String, Optional ByVal Uid As String = "", _ Optional ByVal Pwd As String = "", _ Optional ByVal InCat As String = "", _ Optional ByVal AuthType As String = "") Dim ConnString As String = "" If FrmConfigSetup.cbAuth.SelectedIndex = 0 Then ConnString = "Data Source=" & DSource & ";Initial Catalog=" & InCat & ";Integrated Security=True;Timeout=60;" & "" Else ConnString = "Data Source=" & DSource & ";Initial Catalog=" & InCat & ";Uid=" & Uid & ";Pwd=" & Pwd & ";Timeout=60;" End If SQLConn = New SqlClient.SqlConnection(ConnString) If SQLConn.State = ConnectionState.Open Then SQLConn.Close() SQLConn.Open() Else SQLConn.Open() End If End Sub when it'sTrying to open the connection then goes hang. So, What can I do , please help me.

        Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)

        S Offline
        S Offline
        Samir Ibrahim 0
        wrote on last edited by
        #3

        Why don't you ping that server to make sure it is exist before connecting to it?

        Like car accidents, most hardware problems are due to driver error. Samir R. Ibrahim

        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