-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLiteHandler.cs
More file actions
109 lines (85 loc) · 3.33 KB
/
Copy pathSQLiteHandler.cs
File metadata and controls
109 lines (85 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
using System.Web;
using System.Data.SqlClient;
namespace jpLearningToolOcr
{
public class SQLiteHandler
{
private string connection_string = "Data Source = language_database/jp_lang_data.db";
private SQLiteConnection connection;
private string sqlite_version_cmd = "SELECT SQLITE_VERSION()";
private string sqlite_version;
private string cmd_string;
private SQLiteCommand cmd;
private string cmd_result;
public SQLiteHandler()
{
this.connection = new SQLiteConnection(connection_string);
this.connection.Open();
this.cmd = new SQLiteCommand(sqlite_version_cmd, connection);
this.sqlite_version = cmd.ExecuteScalar().ToString();
Console.WriteLine("SQLite Version: " + this.sqlite_version);
}
public void get_entry(string word)
{
this.cmd_string = $"SELECT entr FROM kanj WHERE txt='{word}';";
this.cmd = new SQLiteCommand(this.cmd_string, this.connection);
using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
ResultForm.query_result.entry_id = reader[0].ToString();
}
}
}
public void get_reading(string entry)
{
this.cmd_string = $"SELECT txt FROM rdng WHERE entr = '{entry}'";
this.cmd = new SQLiteCommand(this.cmd_string, this.connection);
int i = 0;
using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
string current = reader[0].ToString();
ResultForm.query_result.readings.Add(current);
}
}
foreach (string s in ResultForm.query_result.readings)
{
MainForm.tool.resultForm.wordReadingsBox.Items.Add(s);
}
}
public void get_meanings(string entry)
{
this.cmd_string = $"SELECT txt FROM gloss WHERE entr='{entry}'";
this.cmd = new SQLiteCommand(this.cmd_string, this.connection);
int i = 0;
using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
string current = reader[0].ToString();
ResultForm.query_result.meanings.Add(current);
}
}
foreach (string s in ResultForm.query_result.meanings)
{
MainForm.tool.resultForm.wordMeaningsBox.Items.Add(s);
}
}
public void test_command(string word)
{
//this.cmd_string = $"SELECT txt FROM gloss WHERE entr='{entr}'";
//this.cmd = new SQLiteCommand(this.cmd_string, this.connection);
//this.cmd_string = $"SELECT txt FROM kanj WHERE txt='{word}';";
//this.cmd = new SQLiteCommand(this.cmd_string, this.connection);
//var search_word = cmd.ExecuteScalar().ToString();
}
}
}