hello all, I am getting this error while storing an image to the database ... My code is below from... pls help me here... what the wrong i am doing here....
ERROR IS: =========================================================== An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. The name "System.Byte" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. ================================================================
And my code is: ==================================== string File1 = Server.MapPath("DanceTwo.GIF"); FileStream FS; FS = File.Open(File1, FileMode.Open); //a byte array to read the image equle the image size. byte[] ImgByte = new byte[FS.Length]; FS.Read(@ImgByte, 0, Convert.ToInt32(FS.Length)); FS.Close();
//now insert that image in database. CON = new SqlConnection(); CON.ConnectionString = ConfigurationManager.ConnectionStrings["ConWeb"].ConnectionString; SqlCommand CMD = new SqlCommand(); CMD.Connection = CON; CMD.Connection.Open();
CMD.CommandText = "insert into TabImg values(" + ImgByte + ", 'Aadi Image')"; CMD.ExecuteNonQuery();
CMD.Connection.Close(); =============================================
thanks in advance...
|