static void Main(string[] args) { string resource = "DatabaseTest.System.Data.SQLite.dll"; EmbeddedAssembly.Load(resource, "System.Data.SQLite.dll"); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); BibleDao bd = new BibleDao(); Bible a = new Bible("GYGJ", "창세기", 1, 1); Bible b = new Bible("GYGJ", "창세기", 1, 10); Console.WriteLine(bd.GetVerseCount(a)); }
//하나의 Bible객체를 넣으면 phase를 채워서 리턴 public Bible GetSinglePhase(Bible bible) { SQLiteConnection con = new SQLiteConnection(strConn); con.Open(); SQLiteDataReader reader; using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT * FROM " + bible.ver + " WHERE name = '" + bible.name + "' and chapter = " + bible.chapter + " and verse = " + bible.verse; reader = cmd.ExecuteReader(); } while (reader.Read()) { string phase = Convert.ToString(reader["phase"]); bible.phase = phase; } reader.Close(); con.Close(); return(bible); }
//chapter까지 채워진 Bible객체를 넣으면 총 절수를 리턴. public int GetVerseCount(Bible bible) { SQLiteConnection con = new SQLiteConnection(strConn); con.Open(); SQLiteDataReader reader; int count = 0; using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT count(*) as count FROM " + bible.ver + " WHERE name = '" + bible.name + "' and chapter = " + bible.chapter; reader = cmd.ExecuteReader(); } while (reader.Read()) { count = Convert.ToInt32(reader["count"]); } reader.Close(); con.Close(); return(count); }
//처음절과 끝절이 들어간 Bible객체를 넣으면 해당 구간의 BibleList를 리턴 public ArrayList GetMultiPhase(Bible bibleA, Bible bibleB) { SQLiteConnection con = new SQLiteConnection(strConn); con.Open(); SQLiteDataReader reader; ArrayList biblePhaseList = new ArrayList(); using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT * FROM " + bibleA.ver + " WHERE name = '" + bibleA.name + "' and chapter = " + bibleA.chapter + " and verse BETWEEN " + bibleA.verse + " and " + bibleB.verse; reader = cmd.ExecuteReader(); } while (reader.Read()) { string phase = Convert.ToString(reader["phase"]); Bible tempBible = new Bible(bibleA.ver, bibleA.name, bibleA.chapter, bibleA.verse, phase); biblePhaseList.Add(tempBible); } reader.Close(); con.Close(); return(biblePhaseList); }