Select * from soru where dersID=1 order by RND()
Tablolarım ve programım ise;
C# Hep aynı değeri çekiyor? |
18 Mesajlar | 2.511 Okunma |
Select * from soru where dersID=1 order by RND()
SELECT TOP 1 * FROM soru WHERE dersID=1 ORDER BY rnd(soruID)
sayaç++;
lblsoru.Text = sayaç.ToString();
baglan.Open();
OleDbCommand komut = new OleDbCommand("SELECT TOP 1 * FROM soru WHERE dersID=1 ORDER BY rnd(soruID)", baglan);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
label1.Text = (oku["soruBaslik"].ToString());
radioButton1.Text = (oku["A"].ToString());
radioButton2.Text = (oku["B"].ToString());
radioButton3.Text = (oku["C"].ToString());
radioButton4.Text = (oku["D"].ToString());
}
baglan.Close();
SELECT soruID FROM soru WHERE dersID=1
SELECT TOP 1 * FROM soru WHERE dersID=1 AND soruID = {int diziden aldığın yeni değer}
public Form1()
{
InitializeComponent();
}
int sayaç = 0;
OleDbConnection baglan = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database3.accdb");
private void button1_Click(object sender, EventArgs e)
{
sayaç++;
lblsoru.Text = sayaç.ToString();
baglan.Open();
OleDbCommand komut = new OleDbCommand("SELECT TOP 1 * FROM soru WHERE dersID=1 ORDER BY rnd(soruID)", baglan);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
label1.Text = (oku["soruBaslik"].ToString());
radioButton1.Text = (oku["A"].ToString());
radioButton2.Text = (oku["B"].ToString());
radioButton3.Text = (oku["C"].ToString());
radioButton4.Text = (oku["D"].ToString());
}
baglan.Close();
}