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;
}
...全文
188 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
drljw 2013-08-08
  • 打赏
  • 举报
回复
都解决不了吗?
drljw 2013-08-05
  • 打赏
  • 举报
回复
大神们我现在出现的问题不是sql语句的问题 问题是如何在exlipse进行那个title的赋值, 如我问题中android代码那块 我如何将那个title传到调用的webservice的方法中
drljw 2013-08-05
  • 打赏
  • 举报
回复
@是.net里的查询进行赋值的另一种方式 采用的是SqlParameter 进行查询条件的赋值
螃蟹变异了 2013-08-05
  • 打赏
  • 举报
回复
引用 2 楼 guoyoulei520 的回复:
string sql = "select * from HInfo where Title=@title";
这个@是什么?
string sql = "select * from HInfo where Title="+title;
凉凉二点凉 2013-08-05
  • 打赏
  • 举报
回复
string sql = "select * from HInfo where Title=@title";
这个@是什么?
drljw 2013-08-05
  • 打赏
  • 举报
回复
大神们帮忙解决一下 谢谢各位了

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧