ASP.NET Forums
首页 搜索 用户列表 FAQ 注册 登录  
ASP.NET Forums » 探索2005 » 探索Visual Studio 2005 » Re: 请问这个代码哪里有错,怎么改?谢谢!
  Re: 请问这个代码哪里有错,怎么改?谢谢!
帖子发起人: lynn   发起时间: 2007-5-24 3:39 PM   回复数: 1
« 上一主题 下一主题 »
楼主
  2007-5-24, 3:39 PM
lynn 离线,最后访问时间: 5/29/2007 1:32:18 PM lynn

无等级

士兵
等级: 士兵
注册: 2007年5月24日
积分: 2
精华: 0
发贴: 1
请问这个代码哪里有错,怎么改?谢谢!
 

请问这个代码哪里有错,怎么改?谢谢!
protected void LoginButton_Click(object sender, EventArgs e)
    {

        string username = Request.Form["UserName"];
        string userpwd = Request.Form["Password"];
        OleDbConnection con = DB.createCon();
        con.Open();
        OleDbCommand cmd = new OleDbCommand("select * from [user] where username='" + username + "'and userpwd='" + userpwd + "'", con);
        int count = Convert.ToInt32(cmd.ExecuteScalar());
        if (count > 0)
        {
            Response.Redirect("main.aspx");
        }

     }


IP 地址: 已登录   来自: 已登录    返回顶部
第 2 楼
  2007-6-18, 3:57 PM
shigang 离线,最后访问时间: 6/22/2007 6:16:17 PM shigang

无等级

士兵
等级: 士兵
注册: 2007年6月18日
积分: 2
精华: 0
发贴: 2
Re: 请问这个代码哪里有错,怎么改?谢谢!
 
 username + "'and userpwd='" + userpwd + "'", con);
在这一句里,你的and前面少了空格应该写成:username + '" and userpwd = '" + userpwd + "' , con);
希望以后多多交流呀我的qq :664173070
IP 地址: 已登录   来自: 已登录    返回顶部
 第 1 页 总共 1 页 [共有 2 条记录]
ASP.NET Forums » 探索2005 » 探索Visual Studio 2005 » Re: 请问这个代码哪里有错,怎么改?谢谢!

友情链接: hiDotNet官方论坛 | hiDotNet知识库 | 其它友情链接

Asp.Net Forums version: 2.5.2725
(C)Copyright 2004-2007, hiDotNet.com. All Rights Reserved.
意见反馈 | 关于我们

Powered by Community Server :: Forums 中文本地化: hiDotNet.com