您的位置:程序门 -> .net技术 -> c#



求代码,asp下登陆问题的


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


求代码,asp下登陆问题的[已结贴,结贴人:cyxif]
发表于:2007-03-01 17:22:30 楼主
要求是c#的,本人刚开始接触c#和asp.知道是asp的基础知识,但是弄了几天还是不行.来求达人帮助了.
要求输入用户名密码正确则登陆,不正确返回.其中用户名和密码信息在sql2000中.
无论是用登录控件还是其他什么实现都行,只要是c#

ps:麻烦注释写详细,不然估计我看不懂,汗一个.
再次感谢.
发表于:2007-03-01 17:25:311楼 得分:0
忘了说了.只要代码我试过可以,就结贴.
顺便b4下老不结贴的.
发表于:2007-03-01 17:30:132楼 得分:0
查询会不呢?
发表于:2007-03-01 17:30:373楼 得分:10
就是查询之后放到dataset里
发表于:2007-03-01 17:32:034楼 得分:0
会简单的sql查询
要代码.
我知道原理该怎么做,就是不知道代码怎么实现.
谢谢各位了.
明天来结贴.
发表于:2007-03-01 17:41:405楼 得分:20
sqlconnection   ocnconn   =  

newsqlconnection( "server=(local);uid=sa;database=northwind;pwd=; ");  

ocnconn.open();  

dataset   ds   =   new   dataset   ();
sqldataadapter   ada   =   new   sqldataadapter( "select   *   from   products ",conn);
ada.fill(ds, "a ");


ocnconn.close();  
//以上是连数据库,查处用户名和密码
发表于:2007-03-01 17:43:276楼 得分:20
string   name   =   ds.tables[ "a "].rows[0][ "name "].tostring();
string   password   =   ds.tables[ "a "].rows[index][ "password "].tostring();
//然后判断和输入的是否相同
发表于:2007-03-01 17:43:307楼 得分:30
原始方法
try
{
string   ss;//set   a   string   ss   use   for   the   md5   input   password  
ss=system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(userpassword.value,   "md5 ");
oracleconnection   myconnection=new   oracleconnection(configurationsettings.appsettings[ "oracleconnstring "]);
myconnection.open();
try
{
oracledataadapter   mycommand   =   new   oracledataadapter( "select   *     from   log_stu   where   stunum= ' "+userid.value+ " ' ",   myconnection);
dataset   ds   =   new   dataset();
mycommand.fill(ds,   "log_stu ");
//judge   the   login   user   is   or   not   the   system   user
if   (ds.tables[ "log_stu "].rows.count==0)
{
errormessage.text   =   "找不到此用户[ "+userid.value+ "],   请重新输入 ";
return;
}
if   (ss!=ds.tables[ "log_stu "].rows[0][ "pwd "].tostring())  
{
errormessage.text   =   "密码错误[ "+userpassword.value+ "],   请重新输入 ";
return;
}
//query   the   database   and   put   the   user   id   into   the   session
session[ "user_name "]=userid.value;

//login   success   then   goto   page   stu_default.htm
response.redirect( "stu_default.htm ");

}

finally  
{
myconnection.close();
}
}
catch(exception   e)
{
errormessage.text=e.message;
}
}
发表于:2007-03-01 17:44:388楼 得分:20
累……不写了,啥都要写的话太多太多了,你都不说你哪不会怎么告诉你啊
要是哪都不会,建议先学习一个星期
发表于:2007-03-02 08:23:019楼 得分:0
知道怎么从数据库里查询出来数据并放到dataset中了,主要是如何获取用户输入的信息以及具体怎么比较.....
主要就是怎么用用户输入信息构造那个select语句.
比如select*from   user   where   (uid=?   )and   (pwd=?)
那两个问号那具体该怎么写,我写的是两个textbox的id,但是调试时老说应该在那个地方输入;
知道自己很菜了.正在努力的学习中.--!
再次谢谢.
谢谢shrekye(.net学习中……)   和best8625(07蓄势,08翱翔)两位.
发表于:2007-03-02 09:24:2210楼 得分:0
在朋友帮忙下已经解决.谢谢了.


快速检索

最新资讯
热门点击