Hello!
There is a program - one text block ( nameTextBlock ) and one button ( nextButton ) and SQL .
How to make, that when clicking the button, there was a following value of a line from SQL ?
Here is the code, but it displays only the current value from SQL :
private void GetSqlData() { string connectionString = @"Data Source=Jama-Dharma\sqlexpress;Initial Catalog=Cars;Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(connectionString); using (sqlConnection) { string sqlQuery = @"SELECT c.Name FROM CarsCatalog c"; SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConnection); sqlConnection.Open(); SqlDataReader sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { nameTextBlock.Text = sqlReader.GetString(0); } sqlConnection.Close(); } } Thank you all in advance!