passing values of parameter in code itself, must declare scalar var. .error
-
Hi, if a condition is met, my code inserts image into a column of database table. I used below code, passing the value of picture in code, this is giving me "Must declare the scalar variable "@picbyte", i declared its value(code below).any idea why iam getting this error... string filepath = "C:\\Users\\Prakash\\Pictures\\pic.jpg"; FileStream imgfile = new FileStream(filepath, FileMode.Open,FileAccess.Read, FileShare.Read); byte[] picbyte = new byte[Convert.ToInt32(imgfile.Length)]; imgfile.Read(picbyte, 0, System.Convert.ToInt32(imgfile.Length)); SqlCommand cmd3 = new SqlCommand("Insert into " +Label7.Text+"(Picture)"+ " values(@picbyte)",con); cmd3.Parameters.Add("@Picture",System.Data.SqlDbType.Image); cmd3.Parameters["@Picture"].Value=picbyte; cmd3.ExecuteNonQuery(); thanks in advance
modified on Tuesday, January 13, 2009 4:49 PM
-
Hi, if a condition is met, my code inserts image into a column of database table. I used below code, passing the value of picture in code, this is giving me "Must declare the scalar variable "@picbyte", i declared its value(code below).any idea why iam getting this error... string filepath = "C:\\Users\\Prakash\\Pictures\\pic.jpg"; FileStream imgfile = new FileStream(filepath, FileMode.Open,FileAccess.Read, FileShare.Read); byte[] picbyte = new byte[Convert.ToInt32(imgfile.Length)]; imgfile.Read(picbyte, 0, System.Convert.ToInt32(imgfile.Length)); SqlCommand cmd3 = new SqlCommand("Insert into " +Label7.Text+"(Picture)"+ " values(@picbyte)",con); cmd3.Parameters.Add("@Picture",System.Data.SqlDbType.Image); cmd3.Parameters["@Picture"].Value=picbyte; cmd3.ExecuteNonQuery(); thanks in advance
modified on Tuesday, January 13, 2009 4:49 PM
First do you know I cant see errors on your monitor and second it seems you use of Managed C++/CLI so you need to ask on the Managed C++/CLI[^]. ;)
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
First do you know I cant see errors on your monitor and second it seems you use of Managed C++/CLI so you need to ask on the Managed C++/CLI[^]. ;)
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
Hi, iam getting "Must declare the scalar variable "@picbyte" error.... and i supplied the value in my code.. cmd3.Parameters["@Picture"].Value=picbyte; this is a sql code used to insert an image into database for a specific condition, which i'll retrieve in gridview.. i neednot pass the value dynamically so iam passing the value in code itself.. why iam getting this error even though i passed the value... thanks
-
Hi, iam getting "Must declare the scalar variable "@picbyte" error.... and i supplied the value in my code.. cmd3.Parameters["@Picture"].Value=picbyte; this is a sql code used to insert an image into database for a specific condition, which i'll retrieve in gridview.. i neednot pass the value dynamically so iam passing the value in code itself.. why iam getting this error even though i passed the value... thanks