پیام حیاتی
دوشنبه 25 اسفند 1393, 19:11 عصر
سلام
این کدهای ثبت اطلاعات به همراه تصویر در بانک اطلاعاتی هست،میخوام قبل از ذخیره ، ابعاد تصویر رو به اندازه های 80 در 100 تغییر بدم چطور باید این کار رو انجام بدم؟
byte[] img = null;
FileStream fs = new FileStream(imgLoc, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
img = br.ReadBytes((int)fs.Length);
string sql = "insert into contact_reg (c_name , c_family , c_phone , c_mobile , c_phone_work , c_fax , c_email , c_website , c_address , c_description , c_image) values ('" + name.Text + "' , '" + family.Text + "' , '" + phone.Text + "' , '" + mobile.Text + "' , '" + phone_work.Text + "' , '" + fax.Text + "' , '" + email.Text + "' , '" + website.Text + "' , '" + address.Text + "' , '" + description.Text + "' , @img)";
if (con.State != ConnectionState.Open)
con.Open();
command = new SqlCommand(sql, con);
command.Parameters.Add(new SqlParameter("@img", img));
int x = command.ExecuteNonQuery();
con.Close();
MessageBox.Show(x.ToString() + "record(s) saved.");
این کدهای ثبت اطلاعات به همراه تصویر در بانک اطلاعاتی هست،میخوام قبل از ذخیره ، ابعاد تصویر رو به اندازه های 80 در 100 تغییر بدم چطور باید این کار رو انجام بدم؟
byte[] img = null;
FileStream fs = new FileStream(imgLoc, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
img = br.ReadBytes((int)fs.Length);
string sql = "insert into contact_reg (c_name , c_family , c_phone , c_mobile , c_phone_work , c_fax , c_email , c_website , c_address , c_description , c_image) values ('" + name.Text + "' , '" + family.Text + "' , '" + phone.Text + "' , '" + mobile.Text + "' , '" + phone_work.Text + "' , '" + fax.Text + "' , '" + email.Text + "' , '" + website.Text + "' , '" + address.Text + "' , '" + description.Text + "' , @img)";
if (con.State != ConnectionState.Open)
con.Open();
command = new SqlCommand(sql, con);
command.Parameters.Add(new SqlParameter("@img", img));
int x = command.ExecuteNonQuery();
con.Close();
MessageBox.Show(x.ToString() + "record(s) saved.");