Files
WIR-MACHEN-ALLE-ARM/Casino/Database.cs
T

45 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace Casino
{
internal class Database
{
private string myConnectionString = "server=mysql.pb.bib.de;uid=pbg2h25ala;pwd=a7TP2aRv7Xdu;database=pbg2h25ala_Casino";
public ObservableCollection<User> SelectTask()
{
ObservableCollection<User> user = new ObservableCollection<User>();
try
{
MySql.Data.MySqlClient.MySqlConnection myConnection;
myConnection = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
//open a connection
myConnection.Open();
// create a MySQL command and set the SQL statement with parameters
MySqlCommand myCommand = new MySqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = @"SELECT * FROM Nutzer";
// myCommand.Parameters.AddWithValue("@code", "12");
// execute the command and read the results
using MySqlDataReader myReader = myCommand.ExecuteReader();
myConnection.Close();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
Console.WriteLine(ex.Message);
}
return user;
}
}
}