秀纳

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
[Serializable]
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;
    }
    
}
posted on 2006-12-20 16:34  秀纳  阅读(1084)  评论(0编辑  收藏  举报