循环遍历
public void InsertAppraise(Appraise appraise)
{
SqlConnection conn = DBHelp.Getcon();
conn.Open();
foreach(Appraise app in appraise)
{
string sql = string.Format("insert into Appraise(userID,sportsID,appraiseTime,appraiseContent,Support) values({0},{1},getdate(),'{3}','{4}')",app.UserID,app.SportsID,app.AppraiseContent,app.Support1);
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.ExecuteNonQuery();
}
conn.Close();
}
这个的foreach语句怎么个写法?
------解决方案--------------------我猜你是想一次数据库操作执行完所有insert语句...
要是没猜错的话,在sql server里做不到,oracle里用OracleParameter,将OracleParameter.Value设为含有参数值的数组
------解决方案--------------------