111,093
社区成员




FileStream fs = new FileStream(openFile.FileName, FileMode.OpenOrCreate, FileAccess.Read);
byte[] imgbyte = new byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
imgbyte = br.ReadBytes(Convert.ToInt32(fs.Length));
MySQLConnection sqlcon = new MySQLConnection(ConfigurationManager.ConnectionStrings["conStr"].ToString());
sqlcon.Open();
MySQLParameter parID=new MySQLParameter("@GoodsId", DbType.String);
parID.Value = tbxGoodsId.Text.Trim().ToString();
MySQLParameter parNam = new MySQLParameter("@GoodsName", DbType.String);
parNam.Value = tbxGoodsName.Text.Trim().ToString();
MySQLParameter parSize = new MySQLParameter("@GoodsSize", DbType.String);
parSize.Value = tbxGoodsSize.Text.Trim().ToString();
MySQLParameter parAH = new MySQLParameter("@ArticleHeavy", DbType.String);
parAH.Value = tbxGoodsAh.Text.Trim().ToString();
MySQLParameter parAm = new MySQLParameter("@Amount", DbType.String);
parAm.Value = tbxGoodsAmount.Text.Trim().ToString();
MySQLParameter parNW = new MySQLParameter("@NetWeight", DbType.String);
parNW.Value = tbxGoodsNetWeight.Text.Trim().ToString();
MySQLParameter parGW = new MySQLParameter("@GrossWeight", DbType.String);
parGW.Value = tbxGoodsGrossWeight.Text.Trim().ToString();
MySQLParameter parPrice = new MySQLParameter("@Price", DbType.String);
parPrice.Value = tbxGoodsPrice.Text.Trim().ToString();
MySQLParameter parPhoto = new MySQLParameter("@Photo", DbType.Binary);
parPhoto.Value = imgbyte;
MySQLCommand sqlcom = new MySQLCommand("insert into tb_GoodsInfo(GoodsId,GoodsName,GoodsSize,ArticleHeavy,Amount,NetWeight,GrossWeight,Price,Photo) values(@GoodsId,@GoodsName,@GoodsSize,@ArticleHeavy,@Amount,@NetWeight,@GrossWeight,@Price,@Photo)", sqlcon);
sqlcom.CommandType = CommandType.Text;
sqlcom.Parameters.Add(parID);
sqlcom.Parameters.Add(parNam);
sqlcom.Parameters.Add(parSize);
sqlcom.Parameters.Add(parAH);
sqlcom.Parameters.Add(parAm);
sqlcom.Parameters.Add(parNW);
sqlcom.Parameters.Add(parGW);
sqlcom.Parameters.Add(parPrice);
sqlcom.Parameters.Add(parPhoto);
sqlcom.ExecuteNonQuery();
sqlcon.Close();
fs.Close();