| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1362 人关注过本帖
标题:将 varchar 值 'admin' 转换为数据类型为 int 的列时发生语法错误。
只看楼主 加入收藏
水晶心
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2010-7-27
结帖率:80%
收藏
已结贴  问题点数:20 回复次数:4 
将 varchar 值 'admin' 转换为数据类型为 int 的列时发生语法错误。
string str = ConfigurationSettings.AppSettings["dsn"];
        SqlConnection cn = new SqlConnection(str);
        cn.Open();
        string mysql = "select * from admin where aid='" + tbx_aid.Text + "'and apassword ='" + tbx_apassword.Text + "'";
        SqlCommand cm =new SqlCommand(mysql,cn);
        SqlDataReader ur =cm.ExecuteReader();
        if (ur.Read())
        {
           
        Session["aid"]= ur["aid"];
        Session["aname"]= ur ["aname"];
        Session["apower"]= ur ["apower"];
        Session["adep"]= ur ["adep"];
        if (Session["apower"]=="1")
        {

            Response.Redirect("admin1.aspx");
        }
         if (Session["apower"]=="2")
        {
            Response.Redirect("kqmanage.aspx");
        }
         if (Session["apower"]=="3")
        {
            Response.Redirect("lr3.aspx");
        }
        label4.Text = "用户名/密码不正确,请重新输入";
         
     } cn.Close();
将 varchar 值 'admin' 转换为数据类型为 int 的列时发生语法错误。 怎么解决啊,请各位帮帮忙
搜索更多相关主题的帖子: int admin varchar 语法 类型 
2010-08-13 15:57
NewDeveloper
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:48
专家分:159
注 册:2010-7-2
收藏
得分:7 
string mysql = "select * from admin where aid='" + tbx_aid.Text + "'and apassword ='" + tbx_apassword.Text + "'";
我感觉 在and前面要加一个空格
Session["apower"]=="1"——》Session["apower"].ToString()=="1"

2010-08-13 16:05
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
收藏
得分:7 
aid='" + tbx_aid.Text + "'and -->aid=" + tbx_aid.Text + " and

★★★★★为人民服务★★★★★
2010-08-13 16:26
Issac_abc
Rank: 4
来 自:河南
等 级:业余侠客
威 望:2
帖 子:155
专家分:218
注 册:2010-6-17
收藏
得分:0 
2010-08-23 14:54
jiasenlin
Rank: 2
来 自:四川
等 级:论坛游民
帖 子:62
专家分:27
注 册:2009-1-18
收藏
得分:0 
当然错了哦. SQL 错了.
select * from admin where aid='" + tbx_aid.Text + "'and apassword ='" + tbx_apassword.Text + "'";
  where aid???? === 自己看清楚哈.
2010-08-23 16:11
快速回复:将 varchar 值 'admin' 转换为数据类型为 int 的列时发生语法错误。
数据加载中...
 
   



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

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