chk数据库表密码,并在文本框中输入了密码 [英] chk database table password with textbox entered password

查看:90
本文介绍了chk数据库表密码,并在文本框中输入了密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            da = new SqlDataAdapter("select password from login_master where username='"+TextBox1.Text+"'",con);
            ds = new DataSet();
            da.Fill(ds, "login_master");
            DataTable dt = new DataTable();
            dt = ds.Tables[0];


//here i have to chk database table password with textbox entered password in disconnected architecture  



我该怎么办...



感谢Advanced



How can i do that......



Thanks in advanced

推荐答案

编写一个函数frmValidate()返回类型为boolean在If条件中的按钮单击代码中调用此函数.在此功能中,您必须检查文本框中输入的值是否有效.代码如下.
//点击按钮后写上这个

write one function frmValidate() return type as boolean call this function in your button click code in If condition. In this function you have to check the entered value in the textbox is valid or not. code are as given below.
// write this after button click

if FrmValidate() Then
  // show ur next e.g frmMDI.show()
  End if

/*This is your function to check the entered value in the textbox is valid or not if not then it will display messagbox.*/

Private Function FrmValidate() As Boolean
 Dim str, UserName,Password As String
  UserName=ds.Tables("login_master").Rows(0).Item("username")
  Password= ds.Tables(("login_master").Rows(0).Item("password")

if Not TextBox1.text = UserName.Trim Or Not
   TextBox2.text = Password.Trim Then
  str = "Invalid Password or Username.....Try Again."
  MsgBox(str,MsgBoxStyle.Information+vbOKOnly, "Incorrect password or username")
  TextBox1.Clear()
  TextBox2.Clear()
  Return False
End If
Return True
End Function




希望这会帮助你 .
谢谢&问候
Farukh




Hope this will help you .
Thanks & Regards
Farukh


尝试一下,


Try this,


con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        con.open();
        string sql = "select * from login_master where username='"+TextBox1.Text + "'";
        cmd = new SqlCommand(sql, conn);
        da = new SqlDataAdapter(cmd);
        ds = new DataSet();
        da.Fill(ds, "login_master");
    if (ds.Tables[login_master].Rows[0]["password "].ToString()== TextBox2.Text.ToString())
        {
            string url = "Default2.aspx";
            Response.Redirect(url);
        }
    else
        {
            Response.Write("<script>alert('Invalid password');</script>");
        }


con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            da = new SqlDataAdapter("select password from login_master where username='"+TextBox1.Text+"'",con);
            ds = new DataSet();
da.selectcommand=cmd;
            da.Fill(ds, "login_master");
            DataTable dt = new DataTable();
            dt = ds.Tables[0].rows[0];
if(dt.table[0].rows[0]>0)
{
  if(textbox1.text !=dt.table[0].row[0].coloums["password"])
{
response.write("incorrect password");
}
}


这篇关于chk数据库表密码,并在文本框中输入了密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆