问题描述
SqlConnectionconn=newSqlConnection();conn.ConnectionString=conn_str;conn.Open();stringuer_name=TextBox1.Text;stringuer_password=TextBox2.Text;stringcmdText="select*fromTable2";SqlCommandcmd=newSqlCommand(cmdText,conn);DataSetset=newDataSet();SqlDataAdapteradapter=newSqlDataAdapter(cmd);adapter.Fill(set);DataTabletable=set.Tables[0];foreach(DataRowrowintable.Rows){}循环里接下来怎么写啊,
解决方案
解决方案二:
foreach(DataRowrowintable.Rows){stringvalue=row["UserName"];stringpwd=row["password"];}stringcmdText="select*fromTable2";//这里是不是应该加上where条件?
解决方案三:
根据列名访问数据呗
解决方案四:
foreach(DataRowrowintable.Rows){stringname=table.Rows[0]["name"].ToString();stringpassword=table.Rows[0]["password"].ToString();if(uer_name==name){if(uer_password==password){Response.Write("登陆成功!");}else{Response.Write("登陆失败!");}}else{Response.Write("登陆失败!");}}这样可行么?