网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vb.net密码验证,如何用vb制作登录系统验证码

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

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

创新互联建站主要从事网站设计、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务六枝,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

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

VB.NET登陆界面。要验证登录用户名和密码是否正确。登陆后有管理员和普通用户权限判断。管理员只能登录一

将用户名,密码,用户类型存在数据库中,登陆时比较输入的值是否与数据库相同即可。

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程序加密问题

在FormLoad事件里,写如下代码:

If MsgBox("是否打开程序?", MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then

End

End If

大概方法是这样,要想加密码的话,将MsgBox()换成你自己写的对话框。

如果还嫌不够具体的话,你这点儿分就不够。。。


文章题目:vb.net密码验证,如何用vb制作登录系统验证码
当前链接:http://bjjierui.cn/article/phejce.html

其他资讯