有一种简单做法,就是在设计这个表的时候,你把这个字段的默认值设为getdate(),
这样在插入数据库的时候,不管这一列就行了.

解决方案 »

  1.   

    数据库-表-设计-字段(datetime类型)-绑定默认值属性-getdate()
      

  2.   

    SqlConnection conn = new SqlConnection("Data Source=PX-JCZX-05;Initial Catalog=wzgl;Integrated Security=True");
                conn.Open();
                string str1 = comboBox1.SelectedValue();
                string str2 = TextBox3.Text.Trim();
                string str3 = comboBox2.SelectedValue();
                string str4 = dateTimePicker1.Value();                
                string str5 = TextBox5.Text.Trim();
                string str6 = TextBox7.Text.Trim();
                string str7 = dateTimePicker2.Value();
                string sqlStr = "insert into sbcx(dw,xm,gh,xb,csny,jtzz,dh,rksj,zzmm,bz) values('" + str1 + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + str10 + "')";
                SqlCommand cmd = new SqlCommand(sqlStr, conn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                conn.Close();
    这段代码哪里错了?
    怎么显示错误"System.Windows.Forms.ListControl.SelectedValue”是“属性”,但此处被当做“方法”来使用