User datenbank verknüpft

This commit is contained in:
2026-08-20 15:59:54 +02:00
parent 279ea709cd
commit 76b757a85c
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -31,6 +32,21 @@ namespace Casino
// execute the command and read the results // execute the command and read the results
using MySqlDataReader myReader = myCommand.ExecuteReader(); using MySqlDataReader myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
User u = new User(myReader.GetString("name"), myReader.GetInt32("age"), myReader.GetString("passwort"))
{
ID = myReader.GetString("id"),
Name = myReader.GetString("name"),
Alter = myReader.GetInt32("age"),
Passwort = myReader.GetString("passwort"),
Geld = myReader.GetInt32("geld")
};
user.Add(u);
}
myConnection.Close(); myConnection.Close();
} }
catch (MySql.Data.MySqlClient.MySqlException ex) catch (MySql.Data.MySqlClient.MySqlException ex)
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Casino
{ {
public class User public class User
{ {
public string ID { get; } public string ID { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int Alter { get; set; } public int Alter { get; set; }
public string Passwort { get; set; } public string Passwort { get; set; }