tb_StuResult(学生成绩表)表中已经有了stu_id(学生学号)的值,就是想给这个表中的res_single(单选),res_more(多选),res_pd(判断)三个字段添加值,
我写了段代码 哪有错误啊?
code=C#]SqlCommand com = new SqlCommand("insert into tb_StuResult where stu_id='"+ this.lblStuID.Text +" '"
+ "(res_single,res_more,res_pd)"
+ "values('" + int_row1Point + "','"
+ int_row2Point + "','" + int_row3Point + "')", sqlcon);
com.ExecuteNonQuery();[[/code]
我写了段代码 哪有错误啊?
code=C#]SqlCommand com = new SqlCommand("insert into tb_StuResult where stu_id='"+ this.lblStuID.Text +" '"
+ "(res_single,res_more,res_pd)"
+ "values('" + int_row1Point + "','"
+ int_row2Point + "','" + int_row3Point + "')", sqlcon);
com.ExecuteNonQuery();[[/code]
insert into tb_StuResult (res_single,res_more,res_pd) values ('','','') select res_single,res_more,res_pd from yourtable where ...--或者直接插入,不用where
insert into tb_StuResult (stu_id,res_single,res_more,res_pd) values ('','','','')
+ "values('"+this.lblStuID.Text +"','" + int_row1Point + "','"
+ int_row2Point + "','" + int_row3Point + "')", sqlcon);
com.ExecuteNonQuery();
insert 可以加where 吗!