Set up my database through the wizard and copied the connection string it presented to me. But am having problems connecting to the actual DB. Error quoted below. Am I missing out on something?

Private Sub btnDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDB.Click
       Dim strConnect As String = "Data Source=|DataDirectory|\DB\BetJack\MyDatabase#1.sdf;Password=hello12?;Persist Security Info=True"
        Dim myConnection As SqlConnection = New SqlConnection(strConnect)
        Try
            myConnection.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Connection failed")
        End Try
        If myConnection.State = 1 Then
            MessageBox.Show("Connected")
        End If
    End Sub

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: 26 - Error Locating Server/Instance Specified)

_conn = New SqlCeConnection("Data Source = |DataDirectory|\<yourDatabaseName>;password=<your Password>")

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.