I published my project in vs2010 and im trying to deploy it to other computers. I used this connection string that runs smoothly on my pc. This code tries to retrieve the servername and try to connect to database mysysDatabase. This forcely change the app.config.

 Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        If cboServer.Text = "" Then
            MsgBox("Please select Server First", vbInformation, "Server")
        Else
            Try

                Dim _config As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None)
                'the full name of the connection string can be found in the app.config(file)
                ' in the "name" attribute of the connection string
                Dim conne As String = "Server=" & cboServer.Text & ";Database=mysysDatabase;Integrated Security=True"
                'Also tried "Server=" & cboServer.Text & ";Database=mysysDatabase;Trusted_Connection=True"
                _config.ConnectionStrings.ConnectionStrings("System.My.MySettings.SystemConnectionString").ConnectionString = conne
                'Save to file
                _config.Save(System.Configuration.ConfigurationSaveMode.Modified, True)
                'force changes to take effect so that we can start using
                'this new connection string immediately

                System.Configuration.ConfigurationManager.RefreshSection(_config.ConnectionStrings.SectionInformation.Name)
                Configuration.ConfigurationManager.RefreshSection("connectionString")
                My.Settings.Reload()

                'frmSplash.Show()
                'Me.Hide()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            Call frmServer_Load(sender, e)
        End If

    End Sub

I have a module that calls the connection string from the app.congfig then used it troughout the program.

I have a problem after installing it to other computer (client) running in windows xp sp2 and windows 7, Ive tried modifying the connection string but still the client cannot connect to the database. Am i missing something or some error with the code? I already enabled TCP/IP, firewall exection on my PC.

One more thing in publishing the project, what are the pre requisites i need to add? Im using SQL server database 2008 r2 enterprise edition

Thanks for helping

Recommended Answers

All 7 Replies

Are you getting an exact error message regarding why you cannot connect? A quick test to make sure that there is at least connectivit and that SQL is listening is from a remote computer that has the telnet client installed, open a command prompt and type ..

telnet ipaddressOfSQL 1433 [hit enter]

If you see a blinking cursor, you were able to make a connection to that port.

There's no actual error message, From my form load event, Im calling the module to connect from the database, if not a message box will appear indicating that the program cannot connect to the database, somthing like this,

form load event:

Try
            Call main()
            Con.Open()
            MsgBox("Server Connection is Open ! ", vbOKOnly + vbInformation, "Database")
            Me.Hide()
            frmSplash.Show()
        Catch ex As Exception
            MsgBox("Sorry Cannot open Server Connection ", vbCritical, "Database")
            ' Call Server_Load(sender, e)
        End Try

I tried the telnet ipaddofmycomp 1433 and saw blinking cursor

What might be the other problem?

thanks a lot

If you can connect on the port from a remote computer, you have pretty much cleared a network related issue. The problem is likely to be application based. I would first verify that your connection information is correct, that you are actually being autenticated by your data source. You should be able to enable logging and see if the connections are actually being rejected.

To help you find out the problem change the error msgbox to display the exception you've caught, instead of the generic "Sorry Cannot open Server Connection".
Also, since you are using Trusted Connection, I assume windows user from the client machines have been granted login to SQL and access to this db. (I'd ask if the password has expired or has been changed in the current windows session, but you've mentioned xp sp2 and windows 7, so I'm assuming it's at least 2 pcs and hopefully 2 accounts).

@adam k..
Ive checked my ms sql and on security part > logins, my computer name and some NT autority and NT service are available.. I created a new user under logins, I can successfully log in to server using management studio but when I try to expand my database i got an error "the database is not accessible". adding permission to my database objetc, I cannot found the username I created in management studio. How will I fix it?
Hope you understand my explanation. Sorry Im new in setting server client in sql. I always do stand alone

Thanks for helping

I changed the message box to display the exception, here's the error

"Object reference not set to an instance of an object" and
"Log-in failed for user mycompname\Guest"

How will i fix this

Thanks again

I fixed it, Thanks to you guys. For anyone who will also encounter this here's what i did

all on server management studio

I'ved created login id under security and login node, uncheck enforced password policy, then changed my connection string

"Server=" & cboServer.Text & ";Database=mysysDatabase;User ID=id;Password=pass"

then on database node, mydatabase properties, set the permission for the id created, then works everything works. my client can now coonect to database

hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.