急救,Web服务中返回SqlDataReader的值出错,跪求高手帮忙!
public string sqlread(string sqlquery)
{
SqlConnection con = new SqlConnection(connstring);
SqlCommand cmd = new SqlCommand(sqlquery, con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
return reader.GetString(0);
con.Close();
}
else
{
return "error ";
con.Close();
}
调用时出现错误——“您要访问的网页有问题,无法显示。”
[WebMethod(Description = "网站用户登陆服务,用户名Name+密码Password ")]
public string Web_login(string Name, string Password)
{
string sql = "select User_ID from Users where User_Name= ' " + Name + " ' and User_Password= ' " + Password + " ' ";
db sdb = new db();
return sdb.sqlread(sql);
}
请高手帮忙啊!谢谢了
------解决方案--------------------ds.Tables[0].Rows[0][0].ToString()