根据项目负责人编号显示该负责人所对应项目的编号,由于一个负责人可以负责多个项目,这个我比较头疼!
            string connectionString = GetConnString();
            LogCategory logcate = new LogCategory();
            string select_sql3 = "select caID from LogCategory where cuserid="+u.UID+"";
            OleDbConnection myconnection3 = new OleDbConnection(connectionString);
            OleDbCommand mycommand3 = new OleDbCommand(select_sql3, myconnection3);
            myconnection3.Open();
            OleDbDataReader dr3 = mycommand3.ExecuteReader();
            if (dr3 != null)
            {
                while (dr3.Read())
                {
                    得到n个项目编号id;//不知道代码怎么写
                }
                dr3.Close();
            }
            myconnection3.Close();再由项目编号在日志表worklog中找到做这个项目的组员写的日志;绑定在gridview中
            strWhere = "WorkLog.caID= " + id + "";   //由于id多少不定,这个也不会写
            DataSet ds = new WorkLog().GetAll(strWhere); //得到项目组人员的日志数据;

            gridview.DataSource = ds;
            gridview.DataBind();

解决方案 »

  1.   

    附上类worklog中GetAll()函数的代码:
      public DataSet GetAll(string where)
        {
            string orderBy = " ORDER BY ID DESC";
            sql = @"SELECT LogCategory.caName, users.loginName, users.userName, WorkLog.*
    FROM LogCategory, users INNER JOIN WorkLog ON users.userID = WorkLog.userID where LogCategory.caID=WorkLog.caID";
            if (where != string.Empty)
            {
                sql += " and " + where;
            }
            DataSet ds = SQLHelper.Query(sql+orderBy);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return ds;
            }
            return null;
        }