Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    ' Naten cesty k souboru pro aktuln webov poadavek
    Dim webPath As String = Request.ApplicationPath

    'Odstrann zatenho zptnho lomtka 
    webPath = webPath.Substring(0, webPath.LastIndexOf("/"))

    Try
        ' Naten konfiguranho objektu pro aktuln webov poadavek
        Dim config As Configuration = _
     System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(webPath)

        ' Vytvoen novho pipojovacho etzce z hodnot textovch pol
        Dim newConnSetting As New _
        ConnectionStringSettings(txtName.Text, txtValue.Text, txtProvider.Text)
    
        ' Pidn pipojovacho etzce do kolekce
        config.ConnectionStrings.ConnectionStrings.Add(newConnSetting)
    
        ' Uloen zmn
        config.Save()
    Catch cEx As ConfigurationErrorsException
        lblStatus.Text = "Vsledek: " + cEx.ToString()
    Catch ex As System.UnauthorizedAccessException
        ' et pro proces ASP.NET mus mt pro adres oprvnn pro ten i zpis.
        lblStatus.Text = "Vsledek: " + "et pro proces ASP.NET mus mt pro adres
        oprvnn pro ten i zpis."
    Catch eEx As Exception
        lblStatus.Text = "Vsledek: " + eEx.ToString()
    End Try

    ShowConnectionStrings()
End Sub
