vbnet登录,vb net

vb.net 用户登入相关问题

首先要把Label1的属性Visible设置为false,然后双击button1输入:

创新互联成立于2013年,我们提供高端重庆网站建设公司成都网站制作网站设计、网站定制、营销型网站建设微信平台小程序开发、微信公众号开发、营销推广服务,提供专业营销思路、内容策划、视觉设计、程序开发来完成项目落地,为成都玻璃钢坐凳企业提供源源不断的流量和订单咨询。

Dim rs As New Data.DataView()

Dim rs As New DataView()

conn.DataFile = "users.mdb"

conn.SelectCommand = "select top 1 * from users where name='" txtUserName.Text "'and pass='" txtPassword.Text "'"

rs = conn.Select(DataSourceSelectArguments.Empty)

if rs.Count Then

Label1.Visible=true

Session("name") = Trim(txtUserName.Text)

Session("pass") = Trim( txtPassword.Text)

MsgBox("登录成功", MsgBoxStyle.SystemModal)

Response.Redirect("")

Else

MsgBox("对不起!用户名和密码不正确,请重新输入。", MsgBoxStyle.SystemModal)

End If

VB.net 如何实现记住密码 自动登录

代码如下:

/// summary

/// 连接到窗体:通过密码保护信息找回密码!

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void lbl_mibao_Click(object sender, EventArgs e)

{

Getbackpwd getbackpwd = new Getbackpwd();

getbackpwd.Show();

}

/// summary

/// 当该窗体加载时从xml文件中读取用户信息并加载到combox的Items中

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void Addresslist_Load(object sender, EventArgs e)

{

XmlTextReader reader = new XmlTextReader(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

while (reader.Read())

{

//if (reader.LocalName.Equals("Name") || reader.LocalName.Equals("Number"))

if (reader.LocalName.Equals("username"))

{

this.cmbUserName.Items.Add(reader.ReadString());

}

//if (reader.LocalName.Equals("Number"))

//{

// this.label2.Text += reader.ReadString() + "\n";\

//}

}

reader.Close();

}

/// summary

/// 保存用户名到user.xml

/// /summary

//在listcontol上更改SelectedValue时执行从数据库读取密码的事件

private void cmbUserName_SelectedValueChanged(object sender, EventArgs e)

{

string username = cmbUserName.Text.Trim();

string sql = string.Format("select pwd from Admin where Username='{0}'", username);

try

{

SqlCommand command = new SqlCommand(sql, DBHelper.connection);

DBHelper.connection.Open();

SqlDataReader dataReader = command.ExecuteReader();

while (dataReader.Read())

{

txtpwd.Text = (string)dataReader["pwd"];

checkBoxpwd.Checked = true;

}

}

catch

{

MessageBox.Show("数据库操作出错!");

}

finally

{

DBHelper.connection.Close();

}

}

/// summary

/// 记住密码操作

/// /summary

/// param name="sender"/param

/// param name="e"/param

private void checkBoxpwd_Enter(object sender, EventArgs e)

{

bool check = true;

check = checkinput(cmbUserName.Text.Trim());

if ((string)cmbUserName.Text.Trim() == "")

{

MessageBox.Show("请输入用户名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmbUserName.Focus();

}

else

{

if (txtpwd.Text.Trim() == "")

{

MessageBox.Show("请输入密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

txtpwd.Focus();

}

else

{

bool isValidUser = false; // 标识是否为合法用户

string message = ""; // 如果登录失败,显示的消息提示

// 如果验证通过,就显示相应的用户窗体,并将当前窗体设为不可见

if (ValidateInput())

{

// 调用用户验证方法

isValidUser = ValidateUser(cmbUserName.Text, txtpwd.Text, ref message);

// 如果是合法用户,显示相应的窗体

if (isValidUser)

{

if (check == true)

{

XmlDocument doc = new XmlDocument();

doc.Load(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");//(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

XmlElement node = doc.CreateElement("user");

XmlNode xnode = (XmlNode)doc.CreateElement("username");

xnode.InnerText = cmbUserName.Text.Trim();

node.AppendChild(xnode);

doc.DocumentElement.InsertAfter(node, doc.DocumentElement.LastChild);

doc.Save(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

//doc.Load (@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");

}

}

// 如果登录失败,显示相应的消息

else

{

MessageBox.Show(message, "记住密码失败!", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

}

}

}

/// summary

/// 验证当前combox中内容是否已经存在于xml文件中

/// /summary

/// param name="text"/param

/// returns/returns

private bool checkinput(string text)

{

int count;

bool c = true;

for (count = 0; count cmbUserName.Items.Count;count ++ )

{

if (text ==(string )cmbUserName .Items [count])

{

c=false;

}

}

return c;

}

xml文件内容如下:?xml version="1.0" encoding="utf-8"?

person

user

VB.NET用户登录,账号密码正确,却提示密码错误!

Private Sub BtOk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btok.Click

Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Admin.accdb;Persist Security Info=True")

Dim com As OleDbCommand = New OleDbCommand("select * from 用户名", con)

con.Open()

Dim h1 As OleDbDataReader

Dim table As New DataTable

h1 = com.ExecuteReader()

table.Load(h1)

If txtName.Text = "" Then

MsgBox("请输入用户名", MsgBoxStyle.OkCancel + MsgBoxStyle.Exclamation, "错误提示")

ElseIf txtName.Text  "" And txtPasswd.Text = "" Then

MsgBox("请输入密码", MsgBoxStyle.OkCancel + MsgBoxStyle.Exclamation, "错误提示")

ElseIf table.Select("用户名='"  txtName.Text  "'").Length  0 Then

If table.Select("用户名='"  txtName.Text  "'")(0)("密码").ToString = txtPasswd.Text Then

MsgBox("成功登陆", MsgBoxStyle.OkCancel + MsgBoxStyle.Exclamation, "错误提示") Then

Form1.Show()

Me.Visible = False

Exit Sub

Else

MsgBox("密码错误", MsgBoxStyle.OkCancel + MsgBoxStyle.Exclamation, "错误提示")

End If

Else

MsgBox("用户名不存在", MsgBoxStyle.OkCancel + MsgBoxStyle.Exclamation, "错误提示")

Exit Sub

End If

table.Clear()

h1.Close()

con.Close()

End Sub

标题名称:vbnet登录,vb net
网站URL:https://www.cdcxhl.com/article16/dsicegg.html

成都网站建设公司_创新互联,为您提供微信小程序网页设计公司外贸网站建设微信公众号品牌网站建设虚拟主机

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都做网站