日期:2014-05-17 浏览次数:20485 次
connection = new MySqlConnection(connectionString);
MySqlCommand myCommand = new MySqlCommand();
myCommand.Connection = connection;
myCommand.CommandType = System.Data.CommandType.Text;
string sql = "select DISTINCT package_category from all_shop where shopname =?shopname and package_category !=''";
myCommand.CommandText = sql;
myCommand.Parameters.Add(new MySqlParameter("shopname", MySqlDbType.VarChar, 255)).Value = shopname;
MySqlDataReader myReader = null;
connection.Open();
myReader = myCommand.ExecuteReader();
System.Collections.ArrayList people = new System.Collections.ArrayList();
while (myReader.Read())
{
Person p1 = new Person();
p1.package_category = myReader["package_category"].ToString();
people.Add(p1);
}
connection.Close();
Person[] ps = (Person[])people.ToArray(typeof(Person));
context.Response.ContentType = "text/plain";
System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
string json = jss.Serialize(ps);//json
context.Response.Write(json);