Datenbank Nugget Chicken
This commit is contained in:
@@ -8,4 +8,8 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MySql.Data" Version="26.7.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,12 +1,55 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace Casino
|
namespace Casino
|
||||||
{
|
{
|
||||||
internal class Database
|
internal class Database
|
||||||
{
|
{
|
||||||
|
private string myConnectionString = "server=mysql.pb.bib.de;uid=pbg2h25ala;pwd=a7TP2aRv7Xdu;database=pbg2h25ala_Casino";
|
||||||
|
public ObservableCollection<Task> SelectTask()
|
||||||
|
{
|
||||||
|
ObservableCollection<Task> taskList = new ObservableCollection<Task>();
|
||||||
|
|
||||||
|
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 task";
|
||||||
|
// myCommand.Parameters.AddWithValue("@code", "12");
|
||||||
|
|
||||||
|
// execute the command and read the results
|
||||||
|
using MySqlDataReader myReader = myCommand.ExecuteReader();
|
||||||
|
|
||||||
|
while (myReader.Read())
|
||||||
|
{
|
||||||
|
/*int id = myReader.GetInt32("id");
|
||||||
|
int priority = myReader.GetInt32("priority");
|
||||||
|
string title = myReader.GetString("title");
|
||||||
|
double expense = myReader.GetDouble("expense");
|
||||||
|
bool done = myReader.GetBoolean("done");
|
||||||
|
Task t1 = new Task(id, priority, title, expense, done);
|
||||||
|
taskList.Add(t1);
|
||||||
|
Console.WriteLine($"ID: {id}, Priority: {priority}, Title: {title}, Expense: {expense}, Done: {done}");*/
|
||||||
|
}
|
||||||
|
|
||||||
|
myConnection.Close();
|
||||||
|
}
|
||||||
|
catch (MySql.Data.MySqlClient.MySqlException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user