View Full Version : سوال: ارور System Out Of Memory
shytonak
پنج شنبه 20 آبان 1389, 12:36 عصر
سلام دوستان من وفتی می خوام یه عکس از دیتابیس لود کنم با این ارور مواجه می شم مشکل چیه؟
صباح فتحی
پنج شنبه 20 آبان 1389, 12:37 عصر
کد لود رو بزار خب
shytonak
پنج شنبه 20 آبان 1389, 12:45 عصر
private OleDbConnection con;
private OleDbCommand cmd;
private OleDbDataReader re;
private MemoryStream MS;
private byte[] Pic;
private string strQuery = string.Empty;
private string ConnectionString()
{
string ConString = @"Provider=Microsoft.Jet.OLEDB.4.0;"+
@"Data Source=Database2.mdb";
return (ConString);
}
private void btnshow_Click(object sender, EventArgs e)
{
this.con = new OleDbConnection(ConnectionString());
this.strQuery = "select img from tb1 where ID=@ID";
this.cmd = new OleDbCommand(this.strQuery, this.con);
this.cmd.Parameters.AddWithValue
("@ID", this.txtidfornshow.Text.Trim());
this.con.Open();
this.re = this.cmd.ExecuteReader();
if (re.Read())
{
this.Pic = (byte[])re.GetValue(0);
this.MS = new MemoryStream();
this.MS.Write(this.Pic, 0, this.Pic.Length);
this.picboxMyimage.BackgroundImage = Image.FromStream(this.MS);
this.Dispinse();
}
this.Dispinse();
}
private byte[] getByte(string addressPic)
{
this.Pic = File.ReadAllBytes
(addressPic);
return (this.Pic);
}
private void Dispinse()
{
if (this.Pic != null)
{
this.Pic = null;
}
if (this.MS != null)
{
this.MS.Dispose();
}
if (this.re != null)
{
this.re.Close();
}
if (this.con != null)
{
this.con.Close();
}
}
}
صباح فتحی
پنج شنبه 20 آبان 1389, 12:48 عصر
خیلی کد لود رو پیچوندی اینو واسش بنویس:
{
try
{
strsql = "SELECT photo FROM tb_persion where id=" + txtload.Text;
com = new SqlCommand(strsql, con);
con.Open();
byte[]Ax=(byte[])(com.ExecuteScalar());
con.Close();
MemoryStream ms = new MemoryStream(Ax);
picload2.Image = Bitmap.FromStream(ms);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
shytonak
پنج شنبه 20 آبان 1389, 13:15 عصر
دوست من میشه بگید strsql و com چی هستند؟
با تشکر
صباح فتحی
پنج شنبه 20 آبان 1389, 13:26 عصر
اینم برنامش
فقط بانکشو ندارم.گمش کردم
shytonak
پنج شنبه 20 آبان 1389, 22:22 عصر
دوست من نمی دونم مشکل کجاست ولی وقتی باتن لود رو فشار می دم ارور زیر رو می ده.
Object reference not set to an instance of an object.
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.