有一个权限表,power
编号  姓名    入库单   出库单  查询报表
1    张某     1        0        1
2    李某     1        1        1
if语句要达到的效果是判断入库单的值是否等于1.如下;if (入库单=1)   //判断条件不知怎么写;
{
可以打开“入库单”页;
}
else
{
你没有操作权限;
}谢谢!!!

解决方案 »

  1.   

    你会用System.Data.SqlClient.SqlConnection吗?
      

  2.   

    http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx
      

  3.   

    string strConn, strCmd,strR;
            strConn = "你的连接字符串";
            strCmd = "select 入库单 from power where 编号='" + 你的编号 + "'";
            SqlConnection conn = new SqlConnection(strConn);
            SqlCommand cmd = new SqlCommand(strCmd, conn);
            conn.Open();
            try{strR = cmd.ExecuteScalar().ToString();}
            catch { strR = ""; }
            conn.Close();
    strR就是你要的“入库单”。
    if (strR=="1")

    可以打开“入库单”页; 

    else 

    你没有操作权限; 

      

  4.   

    楼上的
    你好像只能读第一行第一列的值吧你要先把植都读出来
    然后循环判断不对啊,那一组数据中有多个值你怎么办
    lz说明白点
    还有,数据库用的是sqlserver 还是oracle
      

  5.   

    如果只查一条就用ExecuteScalar()
    多了就用datatable
    建议你去搜索ado.net
    5楼那个代码你拿去就能用
      

  6.   

    查出数据放入datatable中
    循环遍历
      

  7.   


    一样的,我就改上面兄弟的代码了。大体意思就是这样。要是问代码,最好去看看书。好吗?asp.net2.0之类的。很简单。
    string strConn, strCmd,strR; 
            strConn = "你的连接字符串"; 
            strCmd = "select 1 from power where 编号='" + 你的编号 + "' and 入库单 = 1"; //入库单
             strCmd = "select 1 from power where 编号='" + 你的编号 + "' and 出库单 = 1"; //出库单
             strCmd = "select 1 from power where 编号='" + 你的编号 + "' and 查询报表 = 1"; //查询报表 
            SqlConnection conn = new SqlConnection(strConn);         SqlCommand cmd = new SqlCommand(strCmd, conn); 
            conn.Open(); 
            try{strR = cmd.ExecuteScalar().ToString();} 
            catch { strR = ""; } 
            conn.Close(); 
    strR就是你要的“入库单”。 
    if (strR=="1") 
    {  
    可以打开“入库单”页;  
    }  
    else  
    {  
    你没有操作权限;  
    }  
      

  8.   

    12楼的老师我看不懂,strcmd怎么赋了三个值。咋回事请解释。