ورود

View Full Version : "Must declare the variable '@lenSmallPic



dalaho
دوشنبه 06 آبان 1387, 14:38 عصر
با سلام
من می خواهم عکس در دیتا بیس ذخیره کنم اما با این پیام مواجه شدم.
کد های من اینجاست

Must declare the variable '@lenSmallPic


SqlConnection con1 = new SqlConnection();
int lenSmallPic = FileUploadSmalPic.PostedFile.ContentLength;
byte[] SmallPic = new byte[lenSmallPic];
FileUploadSmalPic.PostedFile.InputStream.Read(Smal lPic, 0, lenSmallPic);


try
{
con1.Open();
SqlCommand cmd = new SqlCommand("insert into testTable(Pic) values (@lenSmallPic)", con1);

cmd.ExecuteNonQuery();
}
catch(Exception exp)
{


}

naeeme
دوشنبه 06 آبان 1387, 15:17 عصر
cmd.Parameters.AddWithValue("@lensmallPic", yourValue)

شما بعد از تعریف cmd باید کد بالا رو بنویسین.

---------------------------
از شما انتظار نمیرفت که از تگ code استفاده نکنین!