[Serializable]
public class ItemInfo
{
public Int64 ItemID;
public string ItemName;
}
public class ItemInfo
{
public Int64 ItemID;
public string ItemName;
}
[WebMethod(Description = "查询物品信息")]
[SoapHeader("Credentails", Direction = SoapHeaderDirection.InOut)]
[XmlInclude(typeof(ItemInfo))]
public ArrayList QueryItemInfo (string ItemName)
{
ArrayList ItemList = new ArrayList();
try
{
Test = new MySqlConnection("");
Test.Open();
TestCmd = new MySqlCommand("select * from `item` where name like ?ItemName", Test);
MySqlParameter PaName = new MySqlParameter("?ItemName", MySqlDbType.VarChar, 255);
PaName.Value = "%" + ItemName + "%";
TestCmd.Parameters.Add(PaName);
TestReader = TestCmd.ExecuteReader();
}
catch (MySqlException ex)
{
EventLog.WriteEntry("QueryItemInfo", "QueryItemInfo:\n\t" + ex.Message);
}
finally
{
if (Test.State == ConnectionState.Open)
{
if (TestReader.HasRows)
{
while (TestReader.Read())
{
ItemInfo item = new ItemInfo();
item.ItemID = (Int64)TestReader.GetValue(0);
item.ItemName = (string)TestReader.GetValue(3);
ItemList.Add(item);
}
}
TestReader.Close();
Test.Close();
}
}
return ItemList;
}
}
[SoapHeader("Credentails", Direction = SoapHeaderDirection.InOut)]
[XmlInclude(typeof(ItemInfo))]
public ArrayList QueryItemInfo (string ItemName)
{
ArrayList ItemList = new ArrayList();
try
{
Test = new MySqlConnection("");
Test.Open();
TestCmd = new MySqlCommand("select * from `item` where name like ?ItemName", Test);
MySqlParameter PaName = new MySqlParameter("?ItemName", MySqlDbType.VarChar, 255);
PaName.Value = "%" + ItemName + "%";
TestCmd.Parameters.Add(PaName);
TestReader = TestCmd.ExecuteReader();
}
catch (MySqlException ex)
{
EventLog.WriteEntry("QueryItemInfo", "QueryItemInfo:\n\t" + ex.Message);
}
finally
{
if (Test.State == ConnectionState.Open)
{
if (TestReader.HasRows)
{
while (TestReader.Read())
{
ItemInfo item = new ItemInfo();
item.ItemID = (Int64)TestReader.GetValue(0);
item.ItemName = (string)TestReader.GetValue(3);
ItemList.Add(item);
}
}
TestReader.Close();
Test.Close();
}
}
return ItemList;
}
}