Created
March 14, 2016 12:52
-
-
Save ozgurkaracam/538a5d65a9ba2de7192c to your computer and use it in GitHub Desktop.
Sorucevap Class'ı
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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