作业辅导网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

作业辅导、毕业论文、学业辅导,请加qq2762169544(微信:2762169544)
查看: 652|回复: 0
打印 上一主题 下一主题

下面的网页程序Login.aspx用于网站的登录验证,当用户击点登录按钮时,执行下列代...

[复制链接]

4万

主题

4万

帖子

4万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
48461
跳转到指定楼层
楼主
发表于 2019-8-19 10:02:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
需要购买此门答案请加qq2762169544(微信:2762169544)
下面的网页程序Login.aspx用于网站的登录验证,当用户击点登录按钮时,执行下列代码。下述代码将连接当前网页文件夹下的PSWeb.mdb数据库,从Login表中查询指定的用户名和密码是否存在。如果用户输入的用户名或密码不正确,给出相应的提示;如果正确,则转向Main.aspx网页。请将下列程序补充完整。
提示:Command对象的常用方法有:ExcuteReader,
ExcuteNonQuery, ExcuteScalar。
  private void btnLogin_Click(object sender, System.EventArgse)
{
string username=txtUserName.Text; // 获取输入的用户名
string passowrd=txtPassword.Text;  // 获取输入的密码
bool canLogin=false;     //
标记变量,是否允许登录,默认为不允许
OleDbConnection conn = newOleDbConnection();
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"
+"DataSource="+__________string sqlString=@"Select [UserName],[Password] From [Login] "
+" where[UserName]='"+username+' and [Password]='"+password+"'";
OleDbCommandcomm = new OleDbCommand(sqlString, conn);
conn.Open();
OleDbDataReader dr = comm. __________
if (__________)  // Login表中有此用户名和密码,则允许登录
{
    canLogin= true;   
}
__________; //
关闭数据库连接
if ( canLogin )               // 如果验证通过允许登录
{
    __________;   // 跳转到main.aspx页面
}
else
/*考虑到main.aspx网页仅允许正确登录的用户才能访问,可以在判断出允许用户登录后,将用户名存入到名为UserName的Session中,再转向Main.aspx网页。请完成下面程序。*/
if ( canLogin )               // 如果验证通过允许登录
{
    __________ // 将用户名存入Session中
    __________;// 跳转到main.aspx页面
}
/*之后,在Main.aspx网页的PageLode事件中,需要加入以下代码,判断存放用户名的Session是否存在,如果不存在,则转向Login.aspx页面,要求用户必须登录。如果该Session存在,则在该页面的名为lblWelcome的标签上显示该用户名。*/
if ( __________  //判断存放用户名的Session是否存在
{
    Response.Redirect("Login.aspx");
}
lblWelcome.Text = "欢迎你," + __________;
42、下面这段程序递归的列出某个目录的内容,起始点是用户指定的路径。
classDirListApp { static voidMain(string[]args) { stringdirectoryPath; do{
Console.WriteLine(“Enter path,ortoquit”); directoryPath=(__________);
if(directoryPath.Length==0) break; DirectoryInfoinfo=(__________); DisplayDirectoryInfo(__________); }while(true); } staticvoid DisplayDirectoryInfo(DirectoryInfo
info) { try { DirectoryInfo[] dirs=info.GetDirectories(); foreach(__________) {
DisplayDirectoryInfo(dir); } FileInfo[]files=info.GetFiles();
foreach(FileInfofiinfiles)
Console.WriteLine(fi); } catch(DirectoryNotFoundExceptionexc) {
Console.WriteLine(“Couldnotfindthedirectory!”); }


















分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
需要购买此门答案请加qq2762169544(微信:2762169544)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作业辅导、毕业论文、学业辅导,考试辅导资料,请加qq2762169544(微信:2762169544)

Archiver|手机版|小黑屋|作业辅导网  

GMT+8, 2025-2-1 13:01 , Processed in 0.036133 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表