rendered paste body#region Usings...
using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Text;
using MySql.Data.MySqlClient;
using LoginEngine.Packets;
using System.Configuration;
using System.Collections.Generic;
#endregion
namespace LoginEngine.QueryBase
{
public static class CharacterList
{
public static IEnumerable<CharacterEntry> LoadCharacters(string accountName)
{
try
{
List<CharacterEntry> characters = new List<CharacterEntry>();
using (MySqlConnection mcc = new MySqlConnection(ConfigurationManager.ConnectionStrings["Mysql"].ConnectionString))
{
string queryName = "SELECT `ID`, `Name`, `Level`, `Breed`, `Profession`, `ZoneID` FROM `character` WHERE Username = " + "'" + accountName + "'";
MySqlCommand mcom = new MySqlCommand(queryName);
mcom.Connection = mcc;
mcc.Open();
MySqlDataAdapter mda = new MySqlDataAdapter(mcom);
DataSet charData = new DataSet();
mda.Fill(charData);
DataTable charTable = charData.Tables[0];
foreach (DataRow charRow in charTable.Rows)
{
CharacterEntry charEntry = new CharacterEntry();
charEntry.Name = charRow["Name"].ToString().PadRight(11, '\u0000');
charEntry.ID = UInt32.Parse(charRow["ID"].ToString());
charEntry.Level = UInt32.Parse(charRow["Level"].ToString());
charEntry.Profession = UInt32.Parse(charRow["Profession"].ToString());
charEntry.Breed = UInt32.Parse(charRow["Breed"].ToString());
charEntry.ZoneID = UInt32.Parse(charRow["ZoneID"].ToString());
characters.Add(charEntry);
}
}
return characters;
}
catch (Exception e)
{
Console.WriteLine(accountName + e.Message);
}
}
}
}