| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 567 人关注过本帖
标题:datareader对象的问题
只看楼主 加入收藏
小小珊玉
Rank: 2
等 级:论坛游民
帖 子:19
专家分:18
注 册:2012-7-18
结帖率:40%
收藏
 问题点数:0 回复次数:0 
datareader对象的问题
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.SessionState;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = "server='localhost';database='workmanager';uid='sa';pwd='zss'";                                          //连接数据库
        SqlConnection con = new SqlConnection(str);                                                                       //创建连接
        con.Open();                                                                                                                                    //打开连接
        string strsql =
        "select * from login where users='" + usernametext.Text + "' and password='" + passwordtext.Text + "'";
        SqlDataAdapter da = new SqlDataAdapter(strsql, con);                                                                //创建适配器
        DataSet ds = new DataSet();

       int count= da.Fill(ds,"login");

             if (count > 0)                                                                                                                                            //登录成功
            {
                Session["name"] = usernametext.Text;                                                                                    //赋予Session
                Session["password"] = passwordtext.Text;                                                                   //赋予Session
                                                                                                                     //赋予Session
            }
            else
            {
                Label1.Text = "登录失败";                                                                                           //登录失败
            }

          SqlCommand cmd = new SqlCommand();
         = "select * from login where isadmin";
        cmd.Connection = con;
        SqlDataReader dr;
        dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            if (dr.GetValue(3).ToString()== "true")
                Response.Redirect("~/teacher.aspx");
            else
                Response.Redirect("~/student.aspx");
        }
        dr.Close();
               con.Close ();
  在datareader 执行executereader()是提示(在 'isadmin' 附近)中指定了非布尔类型的表达式,怎么样解决解决???
搜索更多相关主题的帖子: public 
2013-06-17 21:48
快速回复:datareader对象的问题
数据加载中...
 
   



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

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