zoukankan
html css js c++ java
Asp.Net 判断储存在xml文件中的用户名合法性(登陆操作)
XML文件请见
ASP.Net中实现XMl的标识列(ID列)或自增长列
登陆按钮事件:
private
void
Btn_login_Click(
object
sender, System.EventArgs e)
{
string
username
=
this
.txt_name.Text.Trim();
string
userpass
=
this
.txt_pass.Text.Trim();
string
filename
=
Server.MapPath(
"
.//XMl/User.xml
"
);
string
str
=
OperateXmlByDataSet.UserLogin(filename,
"
username
"
,username,
"
userpass
"
,userpass);
Session[
"
username
"
]
=
str;
if
(str
!=
"
sorry
"
)
{
this
.Lab_flag.Text
=
str
+
"
登陆成功!
"
;
//
登陆成功后的操作 }
else
{
this
.Lab_flag.Text
=
"
请重新登陆
"
;
}
}
文中用到OperateXmlByDataSet的UserLogin方法,代码如下:
用户登陆
#region
用户登陆
public
static
string
UserLogin(
string
strXmlPath,
string
column1 ,
string
values1,
string
column2,
string
values2)
{
try
{
string
strXsdPath
=
strXmlPath.Substring(
0
,strXmlPath.IndexOf(
"
.
"
))
+
"
.xsd
"
;
DataSet ds
=
new
DataSet();
ds.ReadXml(GetXmlFullPath(strXmlPath));
string
str
=
"
sorry
"
;
//
先判断行数
if
(ds.Tables[
0
].Rows.Count
>
0
)
{
for
(
int
i
=
0
; i
<
ds.Tables[
0
].Rows.Count; i
++
)
{
//
如果当前记录为符合Where条件的记录
if
(ds.Tables[
0
].Rows[i][column1].ToString().Trim().Equals(values1))
{
//
循环给找到行的各列赋新值
if
(ds.Tables[
0
].Rows[i][column2].ToString().Trim().Equals(values2))
{
str
=
ds.Tables[
0
].Rows[i][column1].ToString();
return
str;
}
return
str ;
}
}
}
return
str;
}
catch
(Exception e)
{
return
e.Message;
}
}
#endregion
作者:
青羽
查看全文
相关阅读:
ACdream 1224 Robbers (贪心)
HDU 4320 Arcane Numbers 1 (质因子分解)
在脚本中重定向输入
呈现数据
shell中的for、while、until(二)
shell中的for、while、until
C 指针疑虑
结构化命令
fdisk -c 0 350 1000 300命令
PC机上的COM1口和COM2口
原文地址:https://www.cnblogs.com/tenghoo/p/525974.html
最新文章
TCP Flow Control and Data Transfer
TCP Three-way Handshake
hdu 1399 Starship Hakodate-maru (暴力搜索)
hdu 1711 Number Sequence
hdu 1686 Oulipo (kmp)
hdu 2199 Can you solve this equation?
hdu 3746 Cyclic Nacklace
hdu 1358 Period
hdu 2817 A sequence of numbers(快速幂取余)
hdu 2899 Strange fuction (二分)
热门文章
hdu 2141 Can you find it?(二分查找)
hdu 1061 Rightmost Digit
51nod 1117 聪明的木匠 (哈夫曼树)
51nod 1449 砝码称重(贪心算法)
51nod 1065 最小正子段和 (贪心)
HDU 4387 Stone Game (博弈)
51nod 1070 Bash游戏 V4 (斐波那契博弈)
51nod 1605 棋盘问题 (博弈)
HDU 5831 Rikka with Parenthesis II (贪心) -2016杭电多校联合第8场
HDU 5821 Ball (贪心排序) -2016杭电多校联合第8场
Copyright © 2011-2022 走看看