Diacu Paul

Diacu Paul

  • NA
  • 5
  • 729

Problem on selecting every row order by id

Mar 30 2015 5:20 PM
I have a script that should select from table all rows, order by id but only one row per select. This selection is made when a button is pressed. But I think that query is wrong, it selects only first row. Why?
 
private void select()
{
using (Conexiune.getConnection())
{
string select = "SELECT DISTINCT * FROM questions ORDER BY id ASC LIMIT 1";
SQLiteCommand cmd = new SQLiteCommand(select, Conexiune.getConnection());
cmd.CommandType = CommandType.Text;
SQLiteDataReader rdra = cmd.ExecuteReader(CommandBehavior.CloseConnection);
try
{
while (rdra.Read())
{
textBox1.Text = rdra["question"].ToString();
textBox2.Text = rdra["answer1"].ToString();
textBox3.Text = rdra["answer2"].ToString();
textBox4.Text = rdra["answer3"].ToString();
r1 = (int)rdra["option1"];
r2 = (int)rdra["option2"];
r3 = (int)rdra["option3"];
SimulatorManager.Intrebare = textBox1.Text;
}
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
}
}

Answers (4)