Skip to content

Instantly share code, notes, and snippets.

@ozgurkaracam
Created March 14, 2016 12:52
Show Gist options
  • Save ozgurkaracam/538a5d65a9ba2de7192c to your computer and use it in GitHub Desktop.
Save ozgurkaracam/538a5d65a9ba2de7192c to your computer and use it in GitHub Desktop.
Sorucevap Class'ı
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
class scvp
{
public static OleDbConnection baglantiac() {
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=kelimeoyunu.accdb");
return baglanti;
}
public static List<string> sorucek() {
OleDbConnection baglanti=baglantiac();
baglanti.Open();
OleDbCommand kmt = new OleDbCommand("select soru from sorular",baglanti);
OleDbDataReader oku = kmt.ExecuteReader();
List<string> sorular = new List<string> { };
while (oku.Read()){
sorular.Add(oku["soru"].ToString());
}
oku.Close();
baglanti.Close();
return sorular;
}
public static string sorusec(List<string> sorular) {
Random rnd = new Random();
string soru = "";
int indis=rnd.Next(0, sorular.Count);
soru = sorular[indis];
return soru;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment