using System; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; using System.Data; using System.Data.Odbc; using System.Collections; using System.Xml.Serialization; using System.ServiceModel.Configuration; using System.Collections; public class CentreInterface { public CentreInterface() { //Uncomment the following line if using designed components //InitializeComponent(); } public ArrayList getCentres() { string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=Courier;" + "UID=root;" + "PASSWORD=password;" + "OPTION=3"; ArrayList returnedList = new ArrayList(); OdbcConnection DbConnection = new OdbcConnection(MyConString); DbConnection.Open(); OdbcCommand DbCommand = DbConnection.CreateCommand(); DbCommand.CommandText = "SELECT * FROM CENTRE"; OdbcDataReader DbReader = DbCommand.ExecuteReader(); string retString = "usual"; int fCount = DbReader.FieldCount; for (int i = 0; i < fCount; i++) { retString = DbReader.GetName(i); } while (DbReader.Read()) { Centre temp = new Centre(); for (int i = 0; i < fCount; i++) { retString = DbReader.GetString(i); if (i == 0) temp.Name = retString; else if (i == 1) temp.Longitude = float.Parse(retString); else if (i == 2) temp.Lattitude = float.Parse(retString); } returnedList.Add(temp); } DbReader.Close(); DbCommand.Dispose(); DbConnection.Close(); return returnedList; } public ArrayList getCentreNames() { string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=Courier;" + "UID=root;" + "PASSWORD=password;" + "OPTION=3"; ArrayList returnedList = new ArrayList(); OdbcConnection DbConnection = new OdbcConnection(MyConString); DbConnection.Open(); OdbcCommand DbCommand = DbConnection.CreateCommand(); DbCommand.CommandText = "SELECT * FROM CENTRE"; OdbcDataReader DbReader = DbCommand.ExecuteReader(); string retString = "usual"; int fCount = DbReader.FieldCount; for (int i = 0; i < fCount; i++) { retString = DbReader.GetName(i); } while (DbReader.Read()) { string namestring = ""; for (int i = 0; i < fCount; i++) { retString = DbReader.GetString(i); if (i == 0) namestring = retString; } returnedList.Add(namestring); } DbReader.Close(); DbCommand.Dispose(); DbConnection.Close(); return returnedList; } }