我存在的问题的是给数据库写入信息时写不进去!
分别对应SQL里的格式为:varchar,varchar,char,cahr,datetime,datetime,varchar,varchar,varchar
代码如下:
string sdate = this.dateTimePicker1.Value.Date.ToShortDateString();
string sdate2 = this.dateTimePicker2.Value.Date.ToShortDateString();
SqlConnection Tconn = new SqlConnection(strConn);
Tconn.Open();
string Tsql = "insert into Users values('" + this.textBox1.Text + "','" + this.textBox2.Text + "',0)";
string Tsql2 = "insert into Student values('" + this.textBox4.Text + "','" + this.textBox5.Text + "','" + this.textBox6.Text + "','" + this.textBox7.Text + "'," + sdate + "," + sdate2 + ",'" + this.textBox8.Text + "','" + this.textBox9.Text + "','" + this.richTextBox1.Text + "')";
SqlCommand Tcmd = new SqlCommand(Tsql, Tconn);
SqlCommand Tcmd2 = new SqlCommand(Tsql2, Tconn);
MessageBox.Show("" + Tcmd.ExecuteNonQuery().ToString() + "" + Tcmd2.ExecuteNonQuery().ToString() + "");