| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 579 人关注过本帖
标题:登陆框的制作出错
只看楼主 加入收藏
yum2240369
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-8-2
收藏
 问题点数:0 回复次数:3 
登陆框的制作出错

protected void Button1_Click(object sender, EventArgs e)
{
string ConnectionString = "Data Source=data1;user=system;password=manager;";
OracleConnection conn = new OracleConnection(ConnectionString);
try
{
conn.Open();
OracleCommand cmd = conn.CreateCommand();

cmd.CommandText = "select * from yonghu";
cmd.Parameters.Add("@name", OracleType.VarChar, 20);
OracleDataReader odr = cmd.ExecuteReader();
while (odr.Read())
{
Response.Write(odr.GetOracleString(1).ToString());
}
odr.Close();
}
catch (Exception ee)
{
Response.Write(ee.Message);
}
finally
{
conn.Close();
}

Response.Redirect("index.aspx");
}
数据库已经连上了,我想在yonghu这个表中取出用户名和密码并且和textbox1和textbox2中的数据比较,如果一样则
进入到下一个界面index.aspx,请高手帮忙,给出代码,谢谢!

搜索更多相关主题的帖子: 登陆 制作 
2007-08-03 10:14
virusplayer
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2007-8-2
收藏
得分:0 
比较啊
就像你说的,需要比较,可是你就没有比较where username=textbox1.text and pwd=textbox2.text
2007-08-03 14:06
jyoseyi
Rank: 1
等 级:新手上路
帖 子:173
专家分:0
注 册:2007-6-14
收藏
得分:0 

恩,2楼说的对.把where username=textbox1.text and pwd=textbox2.text 加在select * from yonghu后面


try
{
int num =-1
string name=textbox1.text.Trim().Replace("-",";");
string password=textbox2.text.Trim().Replace("-",";"); //Replace("-",";"); 防止SQL注释

conn.Open();

OracleCommand cmd = conn.CreateCommand();

cmd.CommandText = "select * from yonghu where username=and pwd=password";
cmd.Parameters.Add("@name", OracleType.VarChar, 20);

OracleDataReader odr = cmd.ExecuteReader();

DataSet ds = sdr;
num=ds.Tables[0].Rows.Count;
if(num=1)//只有一条记录
{
Response.Redirect("index.aspx");
}
else
{
return;//用户或者密码有错;
}


}
catch (Exception ee)
{
Response.Write(ee.Message);
}
finally
{
conn.Close();
}


我非英雄,广目无双, 我本坏蛋,无限嚣张!
2007-08-03 15:11
欢天喜地
Rank: 2
等 级:论坛游民
威 望:2
帖 子:83
专家分:20
注 册:2007-5-13
收藏
得分:0 
对呀,在sql语句的后面加上where语句就可以了
2007-08-14 18:02
快速回复:登陆框的制作出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014575 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved