Convert.ToInt32的转化有关问题
Convert.ToInt32的转化问题HTML codeSqlDataBase ThisB new SqlDataBase()string CheckSql select c
Convert.ToInt32的转化问题
HTML codeSqlDataBase ThisB = new SqlDataBase(); string CheckSql = "select count(*) from UserList where UserName = '" + UserName + "' and PassWord = '" + PassWord + "'"; int ThisNum = Convert.ToInt32(ThisB.ReturnSQL(CheckSql));
这里老是说:System.FormatException: 输入字符串的格式不正确。
出错就错在:int ThisNum = Convert.ToInt32(ThisB.ReturnSQL(CheckSql))这行,请问该怎么处理,请高手指点下,我看到有人网上说这里输出下,可是我这个是在一个cs文件的类里,我该怎么输出,用response.write又说不允许使用。求教,求教,我是.net新手
[解决办法]你先看(ThisB.ReturnSQL(CheckSql))拿到的是什么
[解决办法]object ob=ThisB.ReturnSQL(CheckSql);
看看是什么
[解决办法]ThisB.ReturnSQL()方法的返回值有问题~
[解决办法]输入字符串的格式不正确 就看看输入的是什么呗,是不是不能转换成int
[解决办法]ReturnSQL返回的什么呀?
CheckSql不就是返回的count吗
[解决办法]SqlDataBase ThisB = new SqlDataBase();
tring CheckSql = "select count(*) from UserList where [UserName] = '" + UserName + "' and [PassWord] = '" + PassWord + "'";
System.Web.HttpContext.Current.Response.Write(ThisB.ReturnSQL(CheckSql)); //看是什么
//int ThisNum = Convert.ToInt32(ThisB.ReturnSQL(CheckSql));
[解决办法]int ThisNum = int.Parse(ThisB.ReturnSQL(CheckSql).ToString().Trim());
[解决办法]