mehdin69
دوشنبه 04 بهمن 1389, 02:09 صبح
سلام دوستان
من یه جدول دارم که اطلاعاتی رو توش ذخیره می کنه از جمله عکس کاربر یه توی جدول فیلد تصویر از جنس image هست و کاری که می خوام بکنم اینه که یه کلاس بنویسم برای add اما نمی دونم چطوری برای عکس این کارو کنم
کلاسم اینطوریه حالا باید کجاشو تغییر بدم ؟؟؟
public int ID;
public string Name;
public string Family;
public string Tell;
public string Address;
public string Image;
public string Degree;
public string Birthday;
dataacces da = new dataacces();
public void Add()
{
string sql = @"INSERT INTO member ( ,mname,mfamily,mtell,maddress,mpicture,mdgree,mbir thday
VALUES ({1},N'{2}',N'{3}',N'{4}',N'{5}',{6},N'{7}',N'{8}' )";
string imgFilePath = this.Image;
FileStream fs = File.OpenRead(imgFilePath);
byte[] fileContents = new BinaryReader(fs).ReadBytes((int)fs.Length);
sql = string.Format(sql,
this.ID,
this.Name,
this.Family,
this.Tell,
this.Address,
fileContents,
this,Degree,
this.Birthday);
da.sqlconnect();
da.sqlcommand(sql);
da.sqldisconnect();
}
نکته : کلاس dataaccsess فقط اتصال با دیتابیس رو برقرار می کنه
و حالا روی دکمه ذخیره هم اینو نوشتم:
member mem = new member();
mem.Name = txtname.Text;
mem.Family = txtfamil.Text;
mem.Tell = txttel.Text;
mem.Address = txtaddress.Text;
mem.Degree = txtdegree.Text;
mem.Birthday = txtbdate.Text;
mem.Image = txtimage.Text;
mem.Add();
this.Close();
که در حال حاضر توی خاصیت this.image فقط مسیر عکس ذخیره می شه
حالا من می خوام ببینم چطوری این مسیر عکس رو توی کلاس تبدیل به خود عکس کنم
مرسی :قلب:
من یه جدول دارم که اطلاعاتی رو توش ذخیره می کنه از جمله عکس کاربر یه توی جدول فیلد تصویر از جنس image هست و کاری که می خوام بکنم اینه که یه کلاس بنویسم برای add اما نمی دونم چطوری برای عکس این کارو کنم
کلاسم اینطوریه حالا باید کجاشو تغییر بدم ؟؟؟
public int ID;
public string Name;
public string Family;
public string Tell;
public string Address;
public string Image;
public string Degree;
public string Birthday;
dataacces da = new dataacces();
public void Add()
{
string sql = @"INSERT INTO member ( ,mname,mfamily,mtell,maddress,mpicture,mdgree,mbir thday
VALUES ({1},N'{2}',N'{3}',N'{4}',N'{5}',{6},N'{7}',N'{8}' )";
string imgFilePath = this.Image;
FileStream fs = File.OpenRead(imgFilePath);
byte[] fileContents = new BinaryReader(fs).ReadBytes((int)fs.Length);
sql = string.Format(sql,
this.ID,
this.Name,
this.Family,
this.Tell,
this.Address,
fileContents,
this,Degree,
this.Birthday);
da.sqlconnect();
da.sqlcommand(sql);
da.sqldisconnect();
}
نکته : کلاس dataaccsess فقط اتصال با دیتابیس رو برقرار می کنه
و حالا روی دکمه ذخیره هم اینو نوشتم:
member mem = new member();
mem.Name = txtname.Text;
mem.Family = txtfamil.Text;
mem.Tell = txttel.Text;
mem.Address = txtaddress.Text;
mem.Degree = txtdegree.Text;
mem.Birthday = txtbdate.Text;
mem.Image = txtimage.Text;
mem.Add();
this.Close();
که در حال حاضر توی خاصیت this.image فقط مسیر عکس ذخیره می شه
حالا من می خوام ببینم چطوری این مسیر عکس رو توی کلاس تبدیل به خود عکس کنم
مرسی :قلب: