string connstr = "Data Source=WWW-0FD4D77EDB7;Initial Catalog=Exercise;Integrated Security=True";
string t1 = textBox1.Text;
string t2 = textBox2.Text;
string t3 = textBox3.Text;
string t4 = textBox4.Text;
string t5 = textBox5.Text;
string t6 = textBox6.Text;
string t7 = textBox7.Text;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
string sqlinsertNumber= "insert into Number(题号) into values(t1) ";
string sqlinsertQuestion="insert into Question(题号,题干) values(t1,t2)";
string sqlinsertSelect = "insert into Select(题号,A,B,C,D) values(t1,t3,t4,t5,t6) ";
string sqlinserAnswer="insert into Answer(题号,答案) values(t1,t7)";
if(MessageBox.Show("您确定要添加吗?","亲爱的同学",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk)==DialogResult.Yes)
{
SqlCommand myCommand1 = new SqlCommand(sqlinsertNumber, conn);
SqlCommand myCommand2 = new SqlCommand(sqlinsertQuestion, conn);
SqlCommand myCommand3 = new SqlCommand(sqlinsertSelect, conn);
SqlCommand myCommand4 = new SqlCommand(sqlinserAnswer, conn);
conn.Close();
MessageBox.Show("ok");
}
这是一个按钮的单击事件
我写得应该没错,编译器没报错,但是输完了就没反应,数据库还是没更新~