网站首页 > 文章中心 > 其它

VB.NET系统登录功能

作者:小编 更新时间:2023-08-17 13:41:18 浏览量:482人看过

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();

}

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

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"))

//{

//}

reader.Close();

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

//在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();

/// 记住密码操作

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();

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");

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

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

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

/// 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;

person

user

vb.net多个用户登录系统怎么做

需要连接数据库,你可以用access做个小型数据库

每次系统登录的时候,根据用户名去数据库查询密码

VB.NET怎么登录带用户名和密码的服务器,链接数据库?

做不到,access数据库是本地数据库,不支持网络访问,建议你换成sql server或者mysql之类的数据库.

注:如果一定要远程访问access也不是不行,有两种办法,一个是服务器如果跟你在同一个局域网,可以把数据库文件夹共享出来,当做共享文件访问.另一种是在那台服务器上装个sql server数据库,sql server可以创建出链接数据库链接到那个access.

基于VB.Net+sql数据库的学生信息管理系统,怎么连接数据库实现登录啊

①.:Access,建立数据库,数据库命名为Database1.mdb.

菜单中找到工程→部件→勾选 ,

勾选后左侧工具栏里就多了两个控件即 ADODC控件和MSHFlexGrid控件.

选择 ADODC控件和MSHFlexGrid控件,放在窗体的合适位置

设置ADODC控件的属性:

右键窗体内ADODC1控件

设置MSHFlexGrid控件的属性:

VB右侧属性表里,找到datasource,选择adodc1

就完事了

vb.net 用户登录

哈哈简单哪

第一步:登陆网页代码

第二步:登陆以后判断是否登陆成功

有两种方法:1.获取网页代码,判断网页字符有无"登陆成功"字样

源代码:

两种方法结合起来用,可以判断网页是否无法连接

以上就是土嘎嘎小编为大家整理的VB.NET系统登录功能相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章