错误 是 GetName() 并非所有的代码路径都返回值
public string GetName()
{
string name = Convert.ToString(Request["name"]);
string sql = "select * from Userinformation where UserName='" + name + "'";
DataSet ds = kunmethod.GetDs(sql);
if (ds.Tables[0].Rows.Count > 0)
{
string dd = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
string ee = Convert.ToString(ds.Tables[0].Rows[0]["Email"]);
string ff = dd+","+ee;
return ff;
//1 字符串,2xml,3 json 4 jquery对象
}
}
------解决方案--------------------
public string GetName()
{
string name = Convert.ToString(Request["name"]);
string sql = "select * from Userinformation where UserName='" + name + "'";
DataSet ds = kunmethod.GetDs(sql);
if (ds.Tables[0].Rows.Count > 0)
{
string dd = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
string ee = Convert.ToString(ds.Tables[0].Rows[0]["Email"]);
string ff = dd+","+ee;
return ff;
//1 字符串,2xml,3 json 4 jquery对象
}
else
{
return "";
}
}
------解决方案--------------------public string GetName()
{
string ff="";
string name = Convert.ToString(Request["name"]);
string sql = "select * from Userinformation where UserName='" + name + "'";
DataSet ds = kunmethod.GetDs(sql);
if (ds.Tables[0].Rows.Count > 0)
{
string dd = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
string ee = Convert.ToString(ds.Tables[0].Rows[0]["Email"]);
ff = dd+","+ee;
//1 字符串,2xml,3 json 4 jquery对象
}
return ff;
}
------解决方案--------------------楼上的正解。
这问题可以结贴了,不用再等了.
C# code
//命名规范对你以后有好处吧
string _strPwd = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
string _srtEmail = Convert.ToString(ds.Tables[0].Rows[0]["Email"]);
string _strResult = dd+","+ee;
return _strResult ;