Q:

VB.net connection string to sql databse

After using the following code, no errors are shown, but my database is not updated once i have made a change using my management system application.
Any recommendations ?
Dim constring As String = Application.StartupPath.ToString() + "\mydatabaseName.mdf"
Public c As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" + constring + ";Integrated      Security=True;User Instance=True"

Sub openConnection()
    conn.ConnectionString = c
    conn.Open()
End Sub

A:

Use the following code:
Dim constring As String = Application.StartupPath.ToString() + "\mydatabaseName.mdf"
Public c As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" + constring +         ";Integrated      Security=True;User Instance=True"

Dim conn As New SqlConnection(c)
    Dim comm As New SqlCommand
    Dim strQuery As New String = "SQL Update Query"

 Try
        comm.CommandText = strQuery
        comm.Connection = conn

        conn.Open()
        comm.ExecuteNonQuery()
    Catch ex As Exception

End Try

Change your connection string to: 
"Data Source=.\SQLEXPRESS;AttachDbFilename=" + constring + ";Initial     Catalog=mydatabaseName;Integrated Security=True;User Instance=True"

Using InitialCatalog helps when there are more than one databases.

