PDA

View Full Version : مبتدی: کمک در رفع خطا



maryam64-69
شنبه 31 فروردین 1392, 16:08 عصر
سلام هنگام درج عکس از این خط خطا می گیره گسی میدونه باید چیکارش کنم
byte[] image = (byte[])com1.ExecuteScalar();
خطای ایجاد شده
Invalid column name 'ImageSize'.

amirzandi
شنبه 31 فروردین 1392, 16:15 عصر
اینکه مشخصه که ، شما داری عکس رو در فیلدی به نام ImageSize می ریزی که در Table شما همچین فیلدی نیست.

maryam64-69
شنبه 31 فروردین 1392, 16:26 عصر
در جدولم این فیلد رو دارم و اطلاعاتم در اون ذخیره است

maryam64-69
شنبه 31 فروردین 1392, 16:33 عصر
این کل کد نمایش عکسه
string strConnection = ("Data Source=SFIX-PC;Initial Catalog=GiahanDarooei;Integrated Security=True");
SqlConnection con1 = new SqlConnection(strConnection);
SqlCommand com1 = new SqlCommand();
com1.Connection = con1;
con1.Open();
com1.CommandText = "Select Count(*) from T_image where GiahName=@GiahName";
com1.Parameters.AddWithValue("@GiahName" , txt2.Text);
int count = (int)com1.ExecuteScalar();
if (count < 1)
{
MessageBox.Show("There isn't any picture with this GiahName");
con1.Close();
return;
}
com1.CommandText = " Select ImageSize from T_giah Where GiahName=@GiahName ";
byte[] image = (byte[])com1.ExecuteScalar();
string strfn = Convert.ToString(DateTime.Now.ToFileTime());
FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write);
fs.Write(image, 0, image.Length);
fs.Flush();
fs.Close();
pictureBox1.Image = Image.FromFile(strfn);
con1.Close();