当前位置:编程学习 > C#/ASP.NET >>

还是这个问题 。。。表述得有点乱,见谅见谅。。。

先通过textbox1判断出用户名是否已存在于数据库表,判断出用户名是否存在后,再判断密码是否正确(textbox2),也是从数据库中读出。还不怎么会用论坛。。。


 if (myds.Tables[0].Rows.Count == 0)
                 {
                     Response.Write("<script>alert('用户名错误或不存在!')</script>");
                 }//用户名存在时,判断密码是否正确
                 else
                 {
                     for (int i = 0; i < myds.Tables[0].Rows.Count;i++)
                         if (myds.Tables[0].Rows[i][2].ToString().Trim()==" + TextBox2.Text.Trim() + ")
 
                        {
                             Response.Redirect("wz.aspx");
                         }
                         else
                    
                         {
                             Response.Write("<script>alert('密码错误!')</script>");
                         }
                     
                     
                 }
 水平有限,求指点。。。谢谢  --------------------编程问答--------------------
 
//直接在数据库里查就行了,干嘛要放到DataTable中去查?
        public static string ExecuteScalarMaxid(string SqlString)
        {

            using (SqlCeConnection connetion = new SqlCeConnection(connectionString))
            {
                connetion.Open();
                SqlCeCommand command = connetion.CreateCommand();
                command.CommandType = CommandType.Text;
                command.CommandText = SqlString;
                string str = command.ExecuteScalar().ToString();
                if (str!="")
                {
                    return str;
                }
                else
                {
                    return "";
                }
            }
        }
--------------------编程问答-------------------- 加上个 
            connection.Close();
--------------------编程问答--------------------   额。。没看题目
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,