-
Notifications
You must be signed in to change notification settings - Fork 1
/
Notatki.txt
86 lines (71 loc) · 2.87 KB
/
Notatki.txt
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
CancellationTokenSource ts;
CancellationToken ct;
ArrayList task;
task.Add( Task.Factory.StartNew(() => chceckIfPrivilageChange(i, ct)));
private void chceckIfPrivilageChange()
{
while (true)
{
var list = connection.GetTablePrivilegesAllUsers(chosenTable);
if (dataGridView2.InvokeRequired)
{
if (connection.isGranteeListTheSame(list))
{
connection.ListGrantee = list;
dataGridView2.BeginInvoke((new Delegate(refreshPreviligeTabele)), list);
}
}
Thread.Sleep(2000);
if (ct.IsCancellationRequested)
{
// another thread decided to cancel
Console.WriteLine("task canceled");
break;
}
}
}
//czy liczba użytkonikówsię zmieniła
private void chceckIfTablesChange()
{
while (true)
{
var list = connection.GetTablesName();
if (dataGridView1.InvokeRequired)
{
if (connection.comparisonTabels(list))
{
connection.ListTabels = list;
dataGridView1.BeginInvoke((new MyDelegate(DelegateMethod)), list);
}
}
Thread.Sleep(1000);
}
}
//SELECT * FROM `db`
//show tabels
//taki tam przykłąd
public void Select(string filename)
{
//cmd.CommandText = "SELECT count(*) from tbUser WHERE UserName = @username and password=@password";
//command.Parameters.Add("@username", txtUserName.Text);
//command.Parameters.Add("@password", txtPassword.Text);
//var count = cmd.ExecuteScalar();
string query = "SELECT * FROM banners WHERE file = '" + filename + "'";
//open connection
if (this.IsConnect() == true) // OpenConnection == isConection
{
//create command and assign the query and connection from the constructor
MySqlCommand cmd = new MySqlCommand(query, connection);
//Get the DataReader from the comment using ExecuteReader
MySqlDataReader myReader = cmd.ExecuteReader();
while (myReader.Read())
{
//Use GetString etc depending on the column datatypes.
Console.WriteLine(myReader.GetInt32(0));
}
myReader.Close();
//close connection
//this.CloseConnection();
}
}