.net - Why cant i store 20 kilibytes image in mysql -
i storing thumbnail size images (less 50kb) in tinyblob
field in mysql using mysqlconnector .net using following code
dim imgcov new imageconverter() dim imgarray byte() = directcast(imgcov.convertto(picturebox1.image , gettype(byte())), byte()) try using conn new mysqlconnection(constr) conn.open dim sql string ="insert services(name,code,emp_id,image) values(@name,@code,@emp_id,@image)" using cmd new mysqlcommand(sql,conn) cmd.parameters.add("@name", mysqldbtype.varchar, 45).value ="ironing" cmd.parameters.add("@code", mysqldbtype.varchar, 45).value ="irn" cmd.parameters.add("@emp_id", mysqldbtype.int32).value =1 cmd.parameters.add("@image", mysqldbtype.longblob, 100).value=imgarray cmd.executenonquery () end using end using msgbox("insert complete") catch ex exception msgbox(ex.message) end try
the problem when store image, doesn't save data. apparent when tried retrieving , started getting errors.
investigating errors, simple increased field size longblob
there after worked fine.
so why cant store 20kb image in tinyblob field?
tinyblob can hold 256 bytes; need @ least regular blob, can store 64kb.
http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html
Comments
Post a Comment