Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/19/19 in Posts

  1. 1 point
  2. using MySql.Data.MySqlClient; namespace Database { class DatabaseTest { public string connectionString = "SERVER=127.0.0.1; DATABASE=db; UID=root; PASSWORD=pw;"; /// <summary> /// Get the Name from Database /// </summary> /// <param name="id">primary key</param> /// <returns>the name</returns> public static string GetName(int id) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM `mytable` WHERE id = @id LIMIT 1"; command.Parameters.AddWithValue("@id", id); //command.Parameters.AddWithValue("@somemore", somemore); using (MySqlDataReader reader = command.ExecuteReader()) { reader.Read(); return reader.GetString("name"); } } } } } it is not testet but should work like this
    1 point
  3. if you can read others code check the wierd players gamemode in database.cs is a good example ...... i will do a simple version for you
    1 point
×
×
  • Create New...