我如何实现对有子节点的tree的删除进行询问然后决定是否删除呢?
还有一个问题,看如下代码;
 string strInsert = "INSERT INTO  diary(riqi,neirong) VALUES('2006-4-8','2222')";
            OleDbCommand inst = new OleDbCommand(strInsert, mydiary);
            inst.ExecuteNonQuery();
可以插入,
但是如果我用一个变量代表当前时间,如何插入呢?上面的时间日期要用变量替换,但直接替换似乎不行

解决方案 »

  1.   

    第一个问题
                string message = "You did not enter a server name. Cancel this operation?";
                string caption = "No Server Name Specified";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result;            // Displays the MessageBox.            result = MessageBox.Show(this, message, caption, buttons,
                    MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 
                    MessageBoxOptions.RightAlign);            if(result == DialogResult.Yes)
                {                // Closes the parent form.                this.Close();            }
    第二个问题
    Datetime t  = Now().toshortDatetime;
    "INSERT INTO  diary(riqi,neirong) VALUES(#"& t &"#,'2222')";
      

  2.   

    第一个问题..在你点击Delete键或其它事件的开头写入if(MessageBox.Show(this, message, caption, buttons,
                    MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 
                    MessageBoxOptions.RightAlign) ==  DialogResult.Yes)
    {
        // 删除
    }
    else
    {
      //其它操作
    }
    -------
    还有一个问题,看如下代码;
     string strInsert = "INSERT INTO  diary(riqi,neirong) VALUES('2006-4-8','2222')";
                OleDbCommand inst = new OleDbCommand(strInsert, mydiary);
                inst.ExecuteNonQuery();
    可以插入,
    但是如果我用一个变量代表当前时间,如何插入呢?上面的时间日期要用变量替换,但直接替换似乎不行
    --------
    INSERT INTO  diary(riqi,neirong) VALUES('2006-4-8','2222')";
    最好把时间都用数据服务器时间. 如下.
    INSERT INTO  diary(riqi,neirong) VALUES(sysdate,'2222')";
      

  3.   

    第二个问题
    Datetime t  = Now().toshortDatetime;
    "INSERT INTO  diary(riqi,neirong) VALUES(#"& t &"#,'2222')";
    ================================================================
    这样似乎不行唉,还麻烦再看一下
      

  4.   

    Datetime t  = Now().toshortDatetime;
    "INSERT INTO  diary(riqi,neirong) VALUES('"+ t.ToString() + "','2222')";
      

  5.   

    to 1bool blnDeleted = true;
    if( yourTreeview.SelectedNode.Nodes.Count > 0 )
    {
        if( MessageBox.Show( yourConfirmMessage, MessageButton ) != DialogResult.OK )
            blnDeleted = false;
    }if( blnDeleted )
        yourTreeview.Nodes.Remove( yourTreeview.SelectedNode );
      

  6.   

    to 2
    string strInsert = "INSERT INTO diary(riqi,neirong) VALUES( @riqi, @neirong )";
    OleDbCommand inst = new OleDbCommand(strInsert, mydiary);inst.Parameters.Add( "@riqi", yourRiqiValue );
    inst.Parameters.Add( "@neirong", yourNeirongValue );inst.ExecuteNonQuery();