求C#大神,求指导。。急。。!!!
private void button1_Click(object sender, EventArgs e)
{
if (textBox4.Text == "")
{
MessageBox.Show("请输入年龄!");
return;
}
if (textBox7.Text == "")
{
MessageBox.Show("请输入工龄!");
return;
}
if (comboBox1.Text == "")
{
MessageBox.Show("请选择部门!");
return;
}
int age = Convert.ToInt32(textBox4.Text);
int gonglin = Convert.ToInt32(textBox7.Text);
String cnno = "Data Source=HP-PC;Initial Catalog=FIRST;Integrated Security=True;Pooling=False";
SqlConnection connection = new SqlConnection(cnno);
string sql = string.Format("Insert into Xinxi values('{0}','{1}','{2}',{3},'{4}','{5}',{6},'{7}','{8}','{9}') ", textBox1.Text, textBox2.Text, textBox3.Text, age, comboBox1.Text, textBox6.Text, gonglin, textBox8.Text, textBox9.Text, textBox10.Text);
connection.Open();
SqlCommand command = new SqlCommand(sql, connection);
//int num = Convert.ToInt32(command.ExecuteScalar());
int num = command.ExecuteNonQuery();
try
{
if (num > 0)
{
MessageBox.Show("添加成功!");
&