/// <summary> /// Soil图片入库 /// </summary> /// <param name="list_picname"></param> public static void InsertSoilPicture(string[] list_picname) { //string pic_date = list_picname[3].Substring(0, list_picname[3].IndexOf('.')); byte[] buffer = Return_Buffer(); //string strSql2 = "insert into MONITOR_PICTURE(INDICATOR_NAME,NUTRIENT_CODE,CROP_CODE,MONITORTIME,PIC_MAP) values(@INDICATOR_NAME,@NUTRIENT_CODE,@CROP_CODE,@MONITORTIME,@PIC_MAP)"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = new SqlCommand("insert_SoilPicture", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@INDICATOR_NAME", list_picname[0]); cmd.Parameters.AddWithValue("@CROP_CODE", DataBaseOperate.getCrop_Code(list_picname[1])); cmd.Parameters.AddWithValue("@NUTRIENT_CODE", DataBaseOperate.getNUTRIENT_CODE(list_picname[2])); cmd.Parameters.AddWithValue("@MONITORTIME", Convert.ToDateTime(list_picname[3]).ToShortDateString()); cmd.Parameters.AddWithValue("@PIC_MAP", buffer); cmd.ExecuteNonQuery(); }
private void btn_InDatabase_Click(object sender, EventArgs e) { int result = 0; string code2 = DataBaseOperate.getNUTRIENT_CODE(res[2]);//获取NUTRIENT_CODE string crop_code = DataBaseOperate.getCrop_Code(res[1]); for (int i = 1; i < dtInfo.Rows.Count - 1; i++) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@PLOTID", dtInfo.Rows[i]["地块编号"]), new SqlParameter("@MONITORTIME", dtInfo.Rows[i]["监测时间"]), new SqlParameter("@CROP_CODE", crop_code), new SqlParameter("@NUTRIENT_CODE", code2), new SqlParameter("@SOIL_NUTRIENT", dtInfo.Rows[i][5]), new SqlParameter("@RECORDTIME", DateTime.Now) }; result = DataBaseOperate.InsertDatabase("insert_Plot_SOILNUTRIENT", param); } if (result > 0) { MessageBox.Show("入库成功!"); } }