小问题,急切寻求帮助!
string TempName=TB1.Text;
string TempPwd=TB2.Text;
string str = "Data Source=2642A6705BA0444;Initial Catalog=luntan;Integrated Security=True ";
SqlConnection Conn = new SqlConnection(str);
string selectr = "select top 1 * from users where userID = ' "+TB1.Text+ " 'and pwd = ' "+TB2.Text+ " ' ";
SqlCommand cmd = new SqlCommand(selectr, Conn);
SqlDataReader odr = null;
Conn.Open();
try
{
odr = cmd.ExecuteReader();
if (odr.Read())
{
string UserName = odr[ "userID "].ToString();
string UserPwd = odr[ "pwd "].ToString();
Label2.Text = UserName;
Label3.Text = UserPwd;
Label4.Text = TempName;
Label5.Text = TempPwd;
if ((UserName == TempName) && (UserPwd == TempPwd))
//这个地方怎么没法判断,是格式不对吗?该怎么改
[解决办法]
单步调试看看UserName 、TempName、UserPwd 、TempPwd的value
我估计TempName、TempPwd里面包含空格
所以条件((UserName == TempName) && (UserPwd == TempPwd))
不成立