I have a simple form with a button and 2 textbox.
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    MysqlConn = New MySqlConnection(ConfigurationManager.ConnectionStrings("db.My.MySettings.dbConnectionString").ToString)
    Try
        'MysqlConn.Dispose()
        'MysqlConn.Close()
        MysqlConn.Open()
        Dim str As String
        str = "SELECT substring_index(substring(path,1,locate(substring_index(path,'\\',-1),path)-2),'\\',-1)as PATH FROM foto where id_product = '" & TextBox2.Text & "'"
        Dim dbCommand As New MySqlCommand(str, MysqlConn)
        Dim dbReader = dbCommand.ExecuteReader
        While dbReader.Read()
            If IsDBNull(dbReader(0)) OrElse String.IsNullOrEmpty(dbReader.GetString(0)) Then
                TextBox1.Text = "0"
            Else
                TextBox1.Text = dbReader.Item("PATH")
            End If
        End While
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        MysqlConn.Dispose()
    End Try
End Sub
when i put in textbox2 "1" i have my desired value. But when i put "2", this id_product dont exist, i dont have "0". It's blank and Textbox1 has my previous value.
What i do wrong ??
 
     
    