Android客户端webservice服务端sql数据库根据Title查询信息
drljw 2013-08-01 10:41:23 webservice代码
/// <summary>
/// 根据标题获取所有信息
/// </summary>
/// <returns>所有信息</returns>
public List<string> selectInfo(string title)
{
List<string> list = new List<string>();
try
{
string sql = "select * from HInfo where Title=@title";
SqlCommand cmd = new SqlCommand(sql, sqlCon);
SqlParameter para = new SqlParameter("@title",title);
cmd.Parameters.Add(para);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//将结果集信息添加到返回向量中
list.Add(reader[0].ToString());
list.Add(reader[1].ToString());
list.Add(reader[2].ToString());
list.Add(reader[3].ToString());
}
reader.Close();
cmd.Dispose();
}
catch (Exception)
{
}
return list;
}
Android代码
其中Title可以接收到
/**
* 获取所有货物的详细信息
*
* @return
*/
public List<HashMap<String, String>> getInfo(String title) {
List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
Log.v(title, "111111111111111111111");
arrayList.clear();
brrayList.clear();
crrayList.clear();
arrayList.add("Title");
brrayList.add(title);
crrayList = Soap.GetWebServre("selectInfo", arrayList, brrayList);
for (int j = 0; j < crrayList.size(); j += 3) {
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap.put("Title", crrayList.get(j));
hashMap.put("Image", crrayList.get(j + 1));
hashMap.put("Info",crrayList.get(j + 2));
list.add(hashMap);
}
return list;
}