I'm trying to connect to a SQLServer 2000 database.
This is my code:
On Form_Load i'm calling the Conect function.
On Form_Leave i'm calling the Disconect function.
When Conect function is called I get this error:Code:Public CNN As New SqlClient.SqlConnection Public rs As New SqlClient.SqlDataAdapter Public Const ID_DB As String = "GesProj" Public Const server As String = "TURION\PRIMAVERA" Public Const user As String = "SA" Public Const Password As String = "SA" Public Sub Conect() Try CNN.ConnectionString = "Data Source=" & server & ";Initial Catalog=" & ID_DB & ";Persist Security Info=True;User ID=" & user & ";Password=" & Password CNN.Open() Exit Sub Catch err As Exception MessageBox.Show("Erro: " & err.Message, "Sem conexão", MessageBoxButtons.OK, MessageBoxIcon.Error) Clipboard.Clear() Clipboard.SetText(err.Message) End Try End Sub Public Sub Disconect() Try CNN.Close() CNN = Nothing Exit Sub Catch err As Exception MessageBox.Show("Erro: " & err.Message, "Sem conexão", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Need help, please.




Reply With Quote