Question Connecting to Godaddy Server - "Direct Access" is enabled, Connection String Issue?

cm1

New member
Joined
Jan 25, 2014
Messages
1
Programming Experience
Beginner
Connecting to Godaddy Server - "Direct Access" is enabled, Connection String Issue?

Hi, I am relatively new to Visual Basics so please bear with me. I have researched quite a bit to see where I went wrong, but can't seem to find the solution. When working between various databases on my computer I am able to get it working fine.

My posted script below works just fine going between dbdouble.mdf and db33.mdf which are both hosted locally (one local DB, the other LOCALDB). However, when trying to connection to Godaddy, which has direct access enabled I am not able to connect and I get the following error from Visual Basic:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Is it a connection string issue? I have tried several other formats, removing initial catalog, changing "data source =" to "server=". I have also changed the link to the ip address with a "xx.xxx.xxx,1443" for the port. But everything I try seems to fail connecting to the db. Does the app.config file need to be uploaded to the server even though I calling it from the app on my computer? Any insight would be appreciated.

app.config
VB.NET:
 <connectionStrings>
        <add name="dbdouble"
            connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Comp\dbdouble.mdf;Integrated Security=True;Connect Timeout=30"
            providerName="System.Data.SqlClient" />
        <add name="db33"
            connectionString="Data Source=(LOCALDB)\V11.0;Initial Catalog=db33;Integrated Security=True;Pooling=False"
            providerName="System.Data.SqlClient" />
        <add name="NAMEOFGODADDYDB"
            connectionString="Data Source=www.linkfromgodaddy.com; Initial Catalog=sameasuseridprovidedbygodaddy; User ID=sameasinitialcataclogprovidedbygodaddy; Password=password-no-quotes;  Trusted_Connection=FALSE"
            providerName="System.Data.SqlClient" />


VB.NET:
'reference added to system.configuration to make configuration manager work
Imports System.Configuration

Public Class Form1

    Dim con As System.Data.SqlClient.SqlConnection
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim dr As System.Data.SqlClient.SqlDataReader
    Dim str As String
    Dim dbdoublecon As String = ConfigurationManager.ConnectionStrings("dbdouble").ConnectionString
    Dim db33con As String = ConfigurationManager.ConnectionStrings("db33").ConnectionString
    Dim appdb12con As String = ConfigurationManager.ConnectionStrings("Appdb12").ConnectionString
    Dim convar As String


check sub

VB.NET:
    Public Sub checker2()
        Select Case NumericUpDown1.Value
            Case Is = 0
                convar = dbdoublecon
            Case Is = 1
                convar = db33con
            Case Is = 2
                convar = appdb12con
        End Select

and finally under the numericupdown_value changed area - I have it so as the numeric dropdown changes so will the text in textbox1 and textbox2 according to the info in the database selected.

Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged
checker2()

Dim id As Integer

id = Val(TextBox1.Text)

con = New SqlClient.SqlConnection(convar)
con.Open()

str = "SELECT id, Name from Info where id=" & id & ""
cmd = New SqlClient.SqlCommand(str, con)

dr = cmd.ExecuteReader()

'use this function for select query
If dr.HasRows = True Then
While dr.Read()
TextBox1.Text = dr(0)
TextBox2.Text = dr(1)
End While
End If

con.Close()
End Sub
 
Top Bottom