I'm trying for a long time, but I can not do it.
I have this simple XAML:
<Window ....>
<Grid>
<Button x:Name="tlacitko" Content="Button" HorizontalAlignment="Left" Height="38" Margin="343,259,0,0" VerticalAlignment="Top" Width="149" Click="Button_Click"/>
<TextBlock x:Name="vypisBlock" HorizontalAlignment="Left" Height="188" Margin="32,25,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="442"/>
</Grid>
</Window>
and this .cs
.. usings ..
namespace Pokus
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
string cs = @"server=localhost;userid=root;
password=vertrigo;database=vzkaznik";
MySqlConnection conn = null;
MySqlDataReader rdr = null;
try
{
conn = new MySqlConnection(cs);
conn.Open();
string stm = "SELECT * FROM elsvo_zpravy";
MySqlCommand cmd = new MySqlCommand(stm, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
string vypis = "";
vypis += (rdr.GetInt32(0) + " - " + rdr.GetString(1) + " - " + rdr.GetString(2) + " - " + rdr.GetString(3) + "\n");
vypisBlock.Text = vypis;
}
}
catch (MySqlException ex)
{
string chyba = "Error: {0}" + ex.ToString(); // doplnit (if = cislo chyby -> hlaska) místo šílenosti co to zobrazuje ted
vypisBlock.Text = chyba;
}
}
}
}
I want the application indicated the contents of the entire table now shows only the last line.
How do I do that?
Thank you