private void dtp日期_ValueChanged(object sender, EventArgs e)
        {            dairyLoad();        }
这段代码能正常执行,这个时间触发后能正常返回值 public void dairyLoad()
        {
            Pub.CC.ExecuteSql("delete dairy1 from dairy1 where dairyname=''");
            DateTime dtp= dtp日期.Value;
            string rtb = rtb内容.Text, tb = tb标题.Text;
            SqlCommand thisCommand = Pub.CC.Conn.CreateCommand();
            thisCommand.Parameters.Add("@a1", dtp);
            thisCommand.CommandText = "select dairytent from dairy1 where dairytime=@a1";//查詢數據庫中相應日期的數據            object countResult = thisCommand.ExecuteScalar();//返回查詢結果的第一行第一列的數據
            if (countResult != null)
            {
                countResult = thisCommand.ExecuteScalar();
                string neirong = countResult.ToString();
                rtb内容.Text = neirong;
                thisCommand.Parameters.Add("@a2", dtp);
                thisCommand.CommandText = "select dairyname from dairy1 where dairytime=@a2";
                object countResult2 = thisCommand.ExecuteScalar();
                string biaoti = countResult2.ToString();
                tb标题.Text = biaoti;
            }
            else if(countResult==null)//數據為空新建文本
            {
                rtb = "";
                tb = "";
                SqlParameter[] pas = new SqlParameter[] {new SqlParameter("@b1", rtb), new SqlParameter("@b2", tb), new SqlParameter("@b3", dtp) };
                
                Pub.CC.ExecuteSql("insert into dairy1 (dairytent,dairyname,dairytime) values (@b1,@b2,@b3)",pas);//在數據庫中建立新的數據
                rtb内容.Text = "";
                tb标题.Text="";
            }
        } private void tvtime_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)//節點雙擊事件
        {
            
            TreeNode tn = this.tvtime.Nodes[0];
            TreeNode may = null;
            foreach (TreeNode nd in tn.Nodes)//找到根节点
            {
                if (nd.Name == "2013Y")
                { may = nd; }
            } 
            DateTime dtp=Convert.ToDateTime(e.Node.Text);
            string str = e.Node.Text;
            SqlCommand thisCommand = Pub.CC.Conn.CreateCommand();
            
            thisCommand.CommandText = ("select dairytent from dairy1 where dairytime LIKE '%"+ str +"%'");            object countResult = thisCommand.ExecuteScalar();
            if (countResult != null)
            {
                countResult = thisCommand.ExecuteScalar();
                string neirong = countResult.ToString();
                rtb内容.Text = neirong;
               
                thisCommand.CommandText = "select dairyname from dairy1 where dairytime like '%"+ str+"%'";
                object countResult2 = thisCommand.ExecuteScalar();
                string biaoti = countResult2.ToString();
                tb标题.Text = biaoti;
            }
            else if (countResult == null)
            {
                
                rtb内容.Text = "";
                tb标题.Text = "";
            }       
        }​而下面这段代码的   if (countResult != null)这个部分则接受到一直是空值,有哪里不一样啊!!!
            {
                countResult = thisCommand.ExecuteScalar();
                string neirong = countResult.ToString();
                rtb内容.Text = neirong;
               
               thisCommand.CommandText = "select dairyname from dairy1 where dairytime like '%"+ str+"%'";
                object countResult2 = thisCommand.ExecuteScalar();
                string biaoti = countResult2.ToString();
                tb标题.Text = biaoti;
            }
而且如果我通过别的时间触发DTP日期_valuechanged时间dairyload代码也将读取空值!!!求大神解答啊!