-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConnectDB.cs
59 lines (47 loc) · 1.37 KB
/
ConnectDB.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
using Game_Center;
using Game_Center.Games.Pong;
using Game_Center.Games;
namespace Game_Center
{
class ConnectDB
{
int score;
int total = 100;
Pong2Players pong2 = new();
#region Declaração
public SQLiteConnection conn = new("Data Source=UserCenter.sdb");
#endregion
public void Conectar()
{
conn.Open();
}
public void Desconectar()
{
conn.Close();
}
public void Update()
{
//GameLobby gl = new();
//score += total;
conn.Open();
score += total;
SQLiteCommand comm = new(conn);
{
comm.CommandText = "SELECT * FROM UserData";
var UserDataId = comm.ExecuteScalar();
if (UserDataId != null /*&& UserDataId != DBNull.Value*/)
{
comm.CommandText = "UPDATE UserData SET Score = " + score + " WHERE Id = @Id";
comm.Parameters.AddWithValue("@Id", UserDataId);
comm.ExecuteNonQuery();
}
}
}
}
}//comm.CommandText = "UPDATE UserData SET Score = '" + score + "' WHERE Id = @Id";