SQLTeam.com | Weblogs | Forums

How to repair and how to do what you meet this two errors



can any one give me the answer of two errors
1)Invalid object name 'sys.databases'.
2) 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: SQL Network Interfaces, error: 25 - Connection string is not valid)
i'm blocked and i cxan't do anything - plese help me


My guess is a typing mistake, e.g. a syntax error. Post the exact command you are using and folk here can check the syntax.

Worth posting the exact SQL for the second issue too.


i try to solve it using videos of youtube but i can' arrive so how to repair this .i click combox to fill it with data bases .i give the code
Public Class ClsCodeGenerator
Public Sub loadserver(ByVal combo As ComboBox)
Dim localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)
Dim rk = localMachine.OpenSubKey("SOFTWARE\Microsoft\Microsoft sql server")
Dim instances = CType(rk.GetValue("InstalledInstances"), String())
If instances.Length > 0 Then
For Each element As String In instances
If element = "MS SQL SERVER" Then
combo.Items.Add(System.Environment.MachineName + "" + element)
End If

            Next element

        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Try

End Sub
Public Sub selectdata(ByVal comboserver As ComboBox, ByVal combodatabase As ComboBox)
    Dim i As Integer

    Dim cn As New SqlConnection("server= " & comboserver.Text & ";database = master; integrated security = true")
    Dim da As New SqlDataAdapter("select name from sys.databases", cn)
    Dim dt As New DataTable
    For i = 0 To dt.Rows.Count - 1




I wold want to display (for debugging) exactly what that concatenated string holds, just in case there is something coming out of the [comboserver] parameter that is unexpected, but the rest looks fine.

I don't have any skill for this application language, so can't help with whether there is any problem with what you are doing, but I can't see anything wrong with:

select name from sys.databases


check if by default remote connections disabled. if yes, then you need to enable TCP/IP connections. if that doesn't work for you then you can also enable "Using both TCP/IP and named pipes".



See required permissions here: