SqlConnection con = new SqlConnection("server=(local);Integrated Security=True;database=varatis");
SqlParameter[] str = new SqlParameter[]{
new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@price", SqlDbType.Int),
new SqlParameter("@image", SqlDbType.Image),
new SqlParameter("@content", SqlDbType.VarChar,200),
new SqlParameter("@state", SqlDbType.Int),
new SqlParameter("@orderid", SqlDbType.Int),
new SqlParameter("@createdate", SqlDbType.DateTime)};
string sql = "insert into goods(name,price,image,content,state,orderid,createdate) values (@name,@price,@image,@content,@state,@orderid,@createdate)";
str[0].Value = goodModel.Name;
str[1].Value = goodModel.Price;
str[2].Value = goodModel.Image;
SqlCommand com = new SqlCommand(sql, con);
com.Parameters.AddRange(str);
con.Open();
int result = com.ExecuteNonQuery();
con.Close();
return result;